Acadia · API Governance Rules

Acadia API Rules

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

25 Rules error 13 warn 8 info 4
View Rules File View on GitHub

Rule Categories

delete get info openapi operation parameter paths response schema security servers

Rules

error
info-title-acadia-prefix
Info title must start with "Acadia"
$.info
error
info-description-required
Info description must be present
$.info
error
info-version-required
Info version must be present
$.info
error
openapi-version-3
Must use OpenAPI 3.0.x
$
error
servers-https-required
Server URLs must use HTTPS
$.servers[*]
warn
paths-kebab-case
Path segments must use kebab-case
$.paths
warn
paths-no-trailing-slash
Paths must not have trailing slashes
$.paths
warn
operation-summary-prefix
Operation summaries must start with "Acadia"
$.paths[*][get,post,put,patch,delete]
error
operation-description-required
Every operation must have a description
$.paths[*][get,post,put,patch,delete]
error
operation-id-required
Every operation must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
operation-id-camel-case
operationId must use camelCase
$.paths[*][get,post,put,patch,delete]
error
operation-tags-required
Every operation must have tags
$.paths[*][get,post,put,patch,delete]
error
parameter-description-required
Parameters must have descriptions
$.paths[*][get,post,put,patch,delete].parameters[*]
info
parameter-pagination-page
List endpoints should support page parameter
$.paths[*].get.parameters[?(@.name == "page")]
info
parameter-pagination-limit
List endpoints should support limit parameter
$.paths[*].get.parameters[?(@.name == "limit")]
error
response-success-required
Every operation must have a 2xx success response
$.paths[*][get,post,put,patch,delete].responses
warn
response-401-required
Protected operations should document 401 response
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
All responses must have descriptions
$.paths[*][get,post,put,patch,delete].responses[*]
warn
schema-description-required
Component schemas must have descriptions
$.components.schemas[*]
info
schema-property-description
Schema properties should have descriptions
$.components.schemas[*].properties[*]
info
schema-property-example
Schema properties should have example values
$.components.schemas[*].properties[*]
error
security-schemes-required
Security schemes must be defined
$
warn
security-bearer-jwt
Acadia uses Bearer JWT authentication
$.components.securitySchemes[*][?(@.type == "http")]
error
get-no-request-body
GET operations must not have a request body
$.paths[*].get
warn
delete-returns-200-or-204
DELETE operations should return 200 or 204
$.paths[*].delete.responses

Spectral Ruleset

Raw ↑
rules:

  # INFO / METADATA
  info-title-acadia-prefix:
    description: Info title must start with "Acadia"
    severity: error
    given: '$.info'
    then:
      field: title
      function: pattern
      functionOptions:
        match: '^Acadia'

  info-description-required:
    description: Info description must be present
    severity: error
    given: '$.info'
    then:
      field: description
      function: truthy

  info-version-required:
    description: Info version must be present
    severity: error
    given: '$.info'
    then:
      field: version
      function: truthy

  # OPENAPI VERSION
  openapi-version-3:
    description: Must use OpenAPI 3.0.x
    severity: error
    given: '$'
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: '^3\.0\.'

  # SERVERS
  servers-https-required:
    description: Server URLs must use HTTPS
    severity: error
    given: '$.servers[*]'
    then:
      field: url
      function: pattern
      functionOptions:
        match: '^https://'

  # PATHS
  paths-kebab-case:
    description: Path segments must use kebab-case
    severity: warn
    given: '$.paths'
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: '^(\/[a-z0-9_\-\{\}]*)*$'

  paths-no-trailing-slash:
    description: Paths must not have trailing slashes
    severity: warn
    given: '$.paths'
    then:
      field: '@key'
      function: pattern
      functionOptions:
        notMatch: '.+\/$'

  # OPERATIONS
  operation-summary-prefix:
    description: Operation summaries must start with "Acadia"
    severity: warn
    given: '$.paths[*][get,post,put,patch,delete]'
    then:
      field: summary
      function: pattern
      functionOptions:
        match: '^Acadia'

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

  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 must use camelCase
    severity: warn
    given: '$.paths[*][get,post,put,patch,delete]'
    then:
      field: operationId
      function: pattern
      functionOptions:
        match: '^[a-z][a-zA-Z0-9]+$'

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

  # PARAMETERS
  parameter-description-required:
    description: Parameters must have descriptions
    severity: error
    given: '$.paths[*][get,post,put,patch,delete].parameters[*]'
    then:
      field: description
      function: truthy

  parameter-pagination-page:
    description: List endpoints should support page parameter
    severity: info
    given: '$.paths[*].get.parameters[?(@.name == "page")]'
    then:
      field: schema.type
      function: enumeration
      functionOptions:
        values:
          - integer

  parameter-pagination-limit:
    description: List endpoints should support limit parameter
    severity: info
    given: '$.paths[*].get.parameters[?(@.name == "limit")]'
    then:
      field: schema.type
      function: enumeration
      functionOptions:
        values:
          - integer

  # RESPONSES
  response-success-required:
    description: Every operation must have a 2xx success response
    severity: error
    given: '$.paths[*][get,post,put,patch,delete].responses'
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ['200']
            - required: ['201']
            - required: ['204']

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

  response-description-required:
    description: All responses must have descriptions
    severity: error
    given: '$.paths[*][get,post,put,patch,delete].responses[*]'
    then:
      field: description
      function: truthy

  # SCHEMAS
  schema-description-required:
    description: Component schemas must have descriptions
    severity: warn
    given: '$.components.schemas[*]'
    then:
      field: description
      function: truthy

  schema-property-description:
    description: Schema properties should have descriptions
    severity: info
    given: '$.components.schemas[*].properties[*]'
    then:
      field: description
      function: truthy

  schema-property-example:
    description: Schema properties should have example values
    severity: info
    given: '$.components.schemas[*].properties[*]'
    then:
      field: example
      function: truthy

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

  security-bearer-jwt:
    description: Acadia uses Bearer JWT authentication
    severity: warn
    given: '$.components.securitySchemes[*][?(@.type == "http")]'
    then:
      field: scheme
      function: enumeration
      functionOptions:
        values:
          - bearer

  # 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

  delete-returns-200-or-204:
    description: DELETE operations should return 200 or 204
    severity: warn
    given: '$.paths[*].delete.responses'
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ['200']
            - required: ['204']