TravelCenters of America · API Governance Rules

TravelCenters of America API Rules

Spectral linting rules defining API design standards and conventions for TravelCenters of America.

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

Rule Categories

ta

Rules

warn
ta-operation-summary-title-case
All operation summaries must use Title Case
$.paths[*][*].summary
error
ta-operationid-required
All operations must have an operationId
$.paths[*][*]
warn
ta-tags-required
All operations must have tags
$.paths[*][*]
error
ta-api-key-auth
API must use API key authentication
$.components.securitySchemes[*]
error
ta-response-200-required
GET operations must have a 200 response
$.paths[*].get.responses
hint
ta-location-id-param
Location-based queries should use location_id parameter consistently
$.paths[*][*].parameters[*][?(@.name=='location_id')]
warn
ta-kebab-case-paths
URL paths should use kebab-case for multi-word segments
$.paths
warn
ta-data-wrapper
Responses should wrap data in a data property
$.components.schemas[?(@property.match(/Response$/))].properties
hint
ta-timestamp-responses
Availability responses should include a timestamp field
$.components.schemas[?(@property.match(/Availability$/))].properties
hint
ta-pagination-for-lists
List responses should include a total count
$.components.schemas[?(@property.match(/ListResponse$/))].properties

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  ta-operation-summary-title-case:
    description: All operation summaries must use Title Case
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z]*(\\s[A-Z][a-zA-Z]*)*$"

  ta-operationid-required:
    description: All operations must have an operationId
    severity: error
    given: "$.paths[*][*]"
    then:
      field: operationId
      function: truthy

  ta-tags-required:
    description: All operations must have tags
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  ta-api-key-auth:
    description: API must use API key authentication
    severity: error
    given: "$.components.securitySchemes[*]"
    then:
      field: type
      function: enumeration
      functionOptions:
        values:
          - apiKey
          - http

  ta-response-200-required:
    description: GET operations must have a 200 response
    severity: error
    given: "$.paths[*].get.responses"
    then:
      field: "200"
      function: truthy

  ta-location-id-param:
    description: Location-based queries should use location_id parameter consistently
    severity: hint
    given: "$.paths[*][*].parameters[*][?(@.name=='location_id')]"
    then:
      field: schema
      function: truthy

  ta-kebab-case-paths:
    description: URL paths should use kebab-case for multi-word segments
    severity: warn
    given: "$.paths"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          patternProperties:
            "^/[a-z][a-z0-9-/{}]*$": {}

  ta-data-wrapper:
    description: Responses should wrap data in a data property
    severity: warn
    given: "$.components.schemas[?(@property.match(/Response$/))].properties"
    then:
      field: data
      function: truthy

  ta-timestamp-responses:
    description: Availability responses should include a timestamp field
    severity: hint
    given: "$.components.schemas[?(@property.match(/Availability$/))].properties"
    then:
      field: timestamp
      function: truthy

  ta-pagination-for-lists:
    description: List responses should include a total count
    severity: hint
    given: "$.components.schemas[?(@property.match(/ListResponse$/))].properties"
    then:
      field: total
      function: truthy