Upwork · API Governance Rules

Upwork API Rules

Spectral linting rules defining API design standards and conventions for Upwork.

21 Rules error 13 warn 8
View Rules File View on GitHub

Rule Categories

get info no openapi operation parameter response schema security servers

Rules

warn
info-title-upwork-prefix
API title must start with "Upwork"
$.info.title
error
info-description-required
API must have a description
$.info
error
info-version-required
API must define a version
$.info
error
openapi-version-3
Specs must use OpenAPI 3.x
$
error
servers-defined
API must define servers
$
error
servers-https-only
Server URLs must use HTTPS
$.servers[*].url
error
operation-summary-required
Every operation must have a summary
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-upwork-prefix
Summaries must start with "Upwork"
$.paths[*][get,post,put,patch,delete].summary
error
operation-id-required
Every operation must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
operation-id-camel-case
operationId should use camelCase
$.paths[*][get,post,put,patch,delete].operationId
error
operation-tags-required
Operations must have tags
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
Operations must have descriptions
$.paths[*][get,post,put,patch,delete]
warn
parameter-description-required
Parameters must have descriptions
$.paths[*][*].parameters[*]
error
response-success-required
Operations must have success responses
$.paths[*][get,post,put,patch,delete].responses
warn
response-401-required
Authenticated operations should define 401
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
Responses must have descriptions
$.paths[*][*].responses[*]
warn
schema-description-required
Schemas should have descriptions
$.components.schemas[*]
warn
schema-type-defined
Schemas should define a type
$.components.schemas[*]
error
security-schemes-defined
Security schemes must be defined
$.components.securitySchemes
error
get-no-request-body
GET operations must not have a request body
$.paths[*].get
error
no-empty-descriptions
Descriptions must not be empty
$..description

Spectral Ruleset

Raw ↑
rules:
  # INFO / METADATA
  info-title-upwork-prefix:
    description: API title must start with "Upwork"
    severity: warn
    given: "$.info.title"
    then:
      function: pattern
      functionOptions:
        match: "^Upwork"

  info-description-required:
    description: API must have a description
    severity: error
    given: "$.info"
    then:
      field: description
      function: truthy

  info-version-required:
    description: API must define a version
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy

  # OPENAPI VERSION
  openapi-version-3:
    description: Specs must use OpenAPI 3.x
    severity: error
    given: "$"
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: "^3\\."

  # SERVERS
  servers-defined:
    description: API must define servers
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

  servers-https-only:
    description: Server URLs must use HTTPS
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  # OPERATIONS
  operation-summary-required:
    description: Every operation must have a summary
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  operation-summary-upwork-prefix:
    description: Summaries must start with "Upwork"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^Upwork "

  operation-id-required:
    description: Every operation must have an operationId
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  operation-id-camel-case:
    description: operationId should use camelCase
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  operation-tags-required:
    description: Operations must have tags
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  operation-description-required:
    description: Operations must have descriptions
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  # PARAMETERS
  parameter-description-required:
    description: Parameters must have descriptions
    severity: warn
    given: "$.paths[*][*].parameters[*]"
    then:
      field: description
      function: truthy

  # RESPONSES
  response-success-required:
    description: Operations must have success responses
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: truthy

  response-401-required:
    description: Authenticated operations should define 401
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      field: "401"
      function: truthy

  response-description-required:
    description: Responses must have descriptions
    severity: error
    given: "$.paths[*][*].responses[*]"
    then:
      field: description
      function: truthy

  # SCHEMAS
  schema-description-required:
    description: Schemas should have descriptions
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy

  schema-type-defined:
    description: Schemas should define a type
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: type
      function: truthy

  # SECURITY
  security-schemes-defined:
    description: Security schemes must be defined
    severity: error
    given: "$.components.securitySchemes"
    then:
      function: truthy

  # HTTP METHOD CONVENTIONS
  get-no-request-body:
    description: GET operations must not have a request body
    severity: error
    given: "$.paths[*].get"
    then:
      field: requestBody
      function: falsy

  # QUALITY
  no-empty-descriptions:
    description: Descriptions must not be empty
    severity: error
    given: "$..description"
    then:
      function: pattern
      functionOptions:
        match: "^.{1,}"