Toyota · API Governance Rules

Toyota API Rules

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

9 Rules error 3 warn 6
View Rules File View on GitHub

Rule Categories

toyota

Rules

warn
toyota-operation-id-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
toyota-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
warn
toyota-paths-kebab-case
API paths must use kebab-case
$.paths[*]~
error
toyota-must-have-tags
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
warn
toyota-vin-path-parameter
VIN path parameters should have proper length constraints
$.paths[*][*].parameters[?(@.name == 'vin' && @.in == 'path')]
error
toyota-must-have-200-or-201
All operations must define a success response
$.paths[*][get,post,put,patch,delete].responses
warn
toyota-pagination-on-list-operations
List operations should support pagination parameters
$.paths[*][get][?(@.operationId =~ /^list/)]
error
toyota-vehicle-endpoints-auth
All vehicle endpoints must require authentication
$.paths[/vehicles*][get,post,put,patch,delete]
warn
toyota-coordinates-format
Latitude and longitude fields should use double format
$.components.schemas[*].properties[latitude,longitude]

Spectral Ruleset

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

  toyota-operation-summary-title-case:
    description: Operation summaries must use Title Case
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 ]*$"

  toyota-paths-kebab-case:
    description: API paths must use kebab-case
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9-]+|/\\{[a-zA-Z0-9]+\\})*$"

  toyota-must-have-tags:
    description: All operations must have at least one tag
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  toyota-vin-path-parameter:
    description: VIN path parameters should have proper length constraints
    severity: warn
    given: "$.paths[*][*].parameters[?(@.name == 'vin' && @.in == 'path')]"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            schema:
              properties:
                minLength:
                  enum: [17]
                maxLength:
                  enum: [17]

  toyota-must-have-200-or-201:
    description: All operations must define a success response
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ["200"]
            - required: ["201"]

  toyota-pagination-on-list-operations:
    description: List operations should support pagination parameters
    severity: warn
    given: "$.paths[*][get][?(@.operationId =~ /^list/)]"
    then:
      field: parameters
      function: truthy

  toyota-vehicle-endpoints-auth:
    description: All vehicle endpoints must require authentication
    given: "$.paths[/vehicles*][get,post,put,patch,delete]"
    severity: error
    then:
      field: security
      function: truthy

  toyota-coordinates-format:
    description: Latitude and longitude fields should use double format
    severity: warn
    given: "$.components.schemas[*].properties[latitude,longitude]"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            format:
              enum: ["double"]