Apifuse · API Governance Rules

Apifuse API Rules

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

10 Rules error 4 warn 6
View Rules File View on GitHub

Rule Categories

info operation parameter response schema servers

Rules

warn
info-title-prefix
API title must start with 'Apifuse'.
$.info
error
info-description-required
API must have a description.
$.info
error
servers-https
All server URLs must use HTTPS.
$.servers[*]
warn
operation-summary-prefix
Operation summaries must start with 'Apifuse'.
$.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-camelcase
OperationId must use camelCase.
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
parameter-description-required
All parameters must have a description.
$.paths[*][get,post,put,patch,delete].parameters[*]
error
response-success-required
Every operation must have a 2xx response.
$.paths[*][get,post,put,patch,delete].responses
warn
schema-property-type-required
Schema properties must have a type defined.
$.components.schemas[*].properties[*]

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  info-title-prefix:
    description: API title must start with 'Apifuse'.
    severity: warn
    given: '$.info'
    then:
      field: title
      function: pattern
      functionOptions:
        match: '^Apifuse'

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

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

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

  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-camelcase:
    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 at least one tag.
    severity: warn
    given: '$.paths[*][get,post,put,patch,delete]'
    then:
      field: tags
      function: truthy

  parameter-description-required:
    description: All parameters must have a description.
    severity: warn
    given: '$.paths[*][get,post,put,patch,delete].parameters[*]'
    then:
      field: description
      function: truthy

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

  schema-property-type-required:
    description: Schema properties must have a type defined.
    severity: warn
    given: '$.components.schemas[*].properties[*]'
    then:
      field: type
      function: truthy