Dexterity · API Governance Rules

Dexterity API Rules

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

8 Rules error 4 warn 3 info 1
View Rules File View on GitHub

Rule Categories

dexterity

Rules

error
dexterity-info-contact
Dexterity APIs must declare a contact block.
$.info
error
dexterity-info-terms
Dexterity APIs must reference termsOfService.
$.info
error
dexterity-server-https
Server URLs must use HTTPS.
$.servers[*].url
warn
dexterity-operation-summary-title-case
Operation summaries must use Title Case.
$.paths..[get,post,put,patch,delete].summary
info
dexterity-operation-id-snake
operationId values use snake_case (FastAPI-style auto-IDs are accepted).
$.paths..[get,post,put,patch,delete].operationId
warn
dexterity-operation-tags-required
Every operation must be tagged.
$.paths..[get,post,put,patch,delete]
error
dexterity-response-2xx-required
Every operation must define at least one 2xx response.
$.paths..[get,post,put,patch,delete].responses
warn
dexterity-validation-error-defined
Mutating operations should document 422 validation errors.
$.paths..[post,put,patch].responses

Spectral Ruleset

Raw ↑
extends: [[spectral:oas, recommended]]
rules:
  dexterity-info-contact:
    description: Dexterity APIs must declare a contact block.
    given: $.info
    severity: error
    then:
      field: contact
      function: truthy
  dexterity-info-terms:
    description: Dexterity APIs must reference termsOfService.
    given: $.info
    severity: error
    then:
      field: termsOfService
      function: truthy
  dexterity-server-https:
    description: Server URLs must use HTTPS.
    given: $.servers[*].url
    severity: error
    then:
      function: pattern
      functionOptions:
        match: '^https://'
  dexterity-operation-summary-title-case:
    description: Operation summaries must use Title Case.
    given: $.paths..[get,post,put,patch,delete].summary
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: '^[A-Z][A-Za-z0-9]*(\s+[A-Z0-9][A-Za-z0-9]*)*$'
  dexterity-operation-id-snake:
    description: operationId values use snake_case (FastAPI-style auto-IDs are accepted).
    given: $.paths..[get,post,put,patch,delete].operationId
    severity: info
    then:
      function: pattern
      functionOptions:
        match: '^[a-z][a-z0-9_]*$'
  dexterity-operation-tags-required:
    description: Every operation must be tagged.
    given: $.paths..[get,post,put,patch,delete]
    severity: warn
    then:
      field: tags
      function: truthy
  dexterity-response-2xx-required:
    description: Every operation must define at least one 2xx response.
    given: $.paths..[get,post,put,patch,delete].responses
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          patternProperties:
            '^2[0-9]{2}$': {}
          minProperties: 1
  dexterity-validation-error-defined:
    description: Mutating operations should document 422 validation errors.
    given: $.paths..[post,put,patch].responses
    severity: warn
    then:
      field: '422'
      function: truthy