Patch · API Governance Rules

Patch API Rules

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

10 Rules error 5 warn 5
View Rules File View on GitHub

Rule Categories

patch

Rules

error
patch-info-title-required
Patch APIs must declare info.title.
$.info
warn
patch-info-contact
Patch APIs must declare an engineering contact.
$.info
error
patch-bearer-auth-required
Patch APIs must declare bearer-auth security scheme.
$.components.securitySchemes
error
patch-server-https
All Patch server URLs must use HTTPS.
$.servers[*].url
warn
patch-tag-titlecase
OpenAPI tags must use Title Case.
$.tags[*].name
warn
patch-summary-titlecase
Operation summaries must use Title Case.
$.paths[*][get,post,put,patch,delete].summary
error
patch-operation-id-camelcase
Operation IDs must be camelCase.
$.paths[*][get,post,put,patch,delete].operationId
error
patch-path-v1-prefix
All API paths must be prefixed with /v1/.
$.paths
warn
patch-error-response-401
Mutating operations must declare a 401 response.
$.paths[*][post,patch,delete].responses
warn
patch-snake-case-properties
JSON property names should be snake_case (Patch convention).
$.components.schemas[*].properties

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  patch-info-title-required:
    description: Patch APIs must declare info.title.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  patch-info-contact:
    description: Patch APIs must declare an engineering contact.
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  patch-bearer-auth-required:
    description: Patch APIs must declare bearer-auth security scheme.
    severity: error
    given: $.components.securitySchemes
    then:
      field: bearerAuth
      function: truthy
  patch-server-https:
    description: All Patch server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: '^https://'
  patch-tag-titlecase:
    description: OpenAPI tags must use Title Case.
    severity: warn
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: '^([A-Z][a-z0-9]*)( [A-Z][a-z0-9]*)*$'
  patch-summary-titlecase:
    description: Operation summaries must use Title Case.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: '^([A-Z][A-Za-z0-9]*)( [A-Za-z0-9]+)*$'
  patch-operation-id-camelcase:
    description: Operation IDs must be camelCase.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: '^[a-z][a-zA-Z0-9]*$'
  patch-path-v1-prefix:
    description: All API paths must be prefixed with /v1/.
    severity: error
    given: $.paths
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: '^/v1/'
  patch-error-response-401:
    description: Mutating operations must declare a 401 response.
    severity: warn
    given: $.paths[*][post,patch,delete].responses
    then:
      field: '401'
      function: truthy
  patch-snake-case-properties:
    description: JSON property names should be snake_case (Patch convention).
    severity: warn
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: '^[a-z][a-z0-9_]*$'