Tango · API Governance Rules

Tango API Rules

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

10 Rules error 1 warn 8
View Rules File View on GitHub

Rule Categories

tango

Rules

warn
tango-operation-ids-camel-case
All operationIds must use camelCase
$.paths[*][*].operationId
warn
tango-paths-kebab-case
All path segments must use kebab-case or be a path parameter
$.paths[*]~
warn
tango-responses-have-content-type
2xx responses must define a content type
$.paths[*][*].responses[?(@property >= 200 && @property < 300)]
warn
tango-parameters-have-descriptions
All parameters must have descriptions
$.paths[*][*].parameters[*]
warn
tango-schemas-have-descriptions
All schema components must have descriptions
$.components.schemas[*]
error
tango-auth-required
All operations must declare security requirements
$.paths[*][*]
warn
tango-operations-have-tags
All operations must have at least one tag
$.paths[*][*]
hint
tango-response-schema-refs
Response schemas should use $ref to reusable components
$.paths[*][*].responses[*].content[*].schema
warn
tango-customer-identifier-path-param
Customer identifier path parameters must be named customerIdentifier
$.paths[*][*].parameters[?(@.in === 'path' && @.name === 'customerId')]
warn
tango-delete-returns-204
DELETE operations should return 204 No Content
$.paths[*].delete.responses

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  tango-operation-ids-camel-case:
    description: All operationIds must use camelCase
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  tango-paths-kebab-case:
    description: All path segments must use kebab-case or be a path parameter
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z][a-z0-9-]*|/\\{[a-zA-Z]+\\})+$"

  tango-responses-have-content-type:
    description: 2xx responses must define a content type
    severity: warn
    given: "$.paths[*][*].responses[?(@property >= 200 && @property < 300)]"
    then:
      field: content
      function: truthy

  tango-parameters-have-descriptions:
    description: All parameters must have descriptions
    severity: warn
    given: "$.paths[*][*].parameters[*]"
    then:
      field: description
      function: truthy

  tango-schemas-have-descriptions:
    description: All schema components must have descriptions
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy

  tango-auth-required:
    description: All operations must declare security requirements
    severity: error
    given: "$.paths[*][*]"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: [security]
            - {}

  tango-operations-have-tags:
    description: All operations must have at least one tag
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  tango-response-schema-refs:
    description: Response schemas should use $ref to reusable components
    severity: hint
    given: "$.paths[*][*].responses[*].content[*].schema"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ["$ref"]
            - properties:
                type:
                  enum: [array, object]

  tango-customer-identifier-path-param:
    description: Customer identifier path parameters must be named customerIdentifier
    severity: warn
    given: "$.paths[*][*].parameters[?(@.in === 'path' && @.name === 'customerId')]"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            name:
              const: customerIdentifier

  tango-delete-returns-204:
    description: DELETE operations should return 204 No Content
    severity: warn
    given: "$.paths[*].delete.responses"
    then:
      function: schema
      functionOptions:
        schema:
          required: ["204"]