Taxi - Describe How Your APIs and Data Relate API Rules

Spectral linting rules defining API design standards and conventions for Taxi - Describe How Your APIs and Data Relate.

8 Rules error 2 warn 6
View Rules File View on GitHub

Rule Categories

taxi

Rules

warn
taxi-operation-ids-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
taxi-path-kebab-case
Path segments must use kebab-case
$.paths[*]~
error
taxi-operation-summary-exists
All operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
taxi-operation-description-exists
All operations must have a description
$.paths[*][get,post,put,patch,delete]
error
taxi-response-200-exists
All operations must define a 200 response
$.paths[*][get,post,put,patch,delete].responses
warn
taxi-tags-title-case
Tags must use Title Case
$.tags[*].name
warn
taxi-info-license
API must include license information (open source)
$.info
warn
taxi-schema-descriptions
Component schemas must have descriptions
$.components.schemas[*]

Spectral Ruleset

Raw ↑
rules:
  taxi-operation-ids-camel-case:
    description: Operation IDs must use camelCase
    message: "operationId '{{value}}' must use camelCase"
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  taxi-path-kebab-case:
    description: Path segments must use kebab-case
    message: "Path segment must use kebab-case: {{path}}"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9{}-]+)*$"

  taxi-operation-summary-exists:
    description: All operations must have a summary
    message: "Operation at '{{path}}' is missing a summary"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  taxi-operation-description-exists:
    description: All operations must have a description
    message: "Operation at '{{path}}' is missing a description"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  taxi-response-200-exists:
    description: All operations must define a 200 response
    message: "Operation at '{{path}}' must define a 200/201 success response"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ["200"]
            - required: ["201"]

  taxi-tags-title-case:
    description: Tags must use Title Case
    message: "Tag '{{value}}' must use Title Case"
    severity: warn
    given: "$.tags[*].name"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 ]*$"

  taxi-info-license:
    description: API must include license information (open source)
    message: "Open source API must include license info"
    severity: warn
    given: "$.info"
    then:
      field: license
      function: truthy

  taxi-schema-descriptions:
    description: Component schemas must have descriptions
    message: "Schema '{{path}}' is missing a description"
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy