Toyota · API Governance Rules

Toyota API Rules

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

18 Rules error 4 warn 12 info 2
View Rules File View on GitHub

Rule Categories

error no path query schema security servers 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]
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-expected-domain
Server URLs should be on the toyota.com domain.
$.servers[*].url
warn
path-params-casing
Path parameters should be snake_case (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
info
query-params-casing
Query parameters should be snake_case (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
info
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
security-schemes-defined
Security schemes should be defined in components.
$.components
warn
error-schema-defined
A shared error schema (Error) should be defined for error payloads.
$.components.schemas
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# toyota — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 2/2 servers on toyota.com
#   - path-params-casing: snake @ 91% (n=23)
#   - query-params-casing: snake @ 53% (n=19)
#   - operationid-casing: camel @ 100% (n=25)
#   - schema-names-casing: pascal @ 100% (n=30)
#   - schema-properties-casing: snake @ 57% (n=153)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: Error
#   - pagination params observed: ['limit', 'offset', 'page']
#   - merge: kept 9 existing, added 9 measured, upgraded 0
#   - added: servers-https-only, servers-expected-domain, path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, security-schemes-defined, error-schema-defined, no-empty-descriptions
extends:
  - spectral:oas
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
  servers-https-only:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-expected-domain:
    description: Server URLs should be on the toyota.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: toyota\.com
  path-params-casing:
    description: Path parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*].parameters[?(@.in=='path')].name
    then:
      function: casing
      functionOptions:
        type: snake
  query-params-casing:
    description: Query parameters should be snake_case (the dominant convention in this API).
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: snake
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: pascal
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  security-schemes-defined:
    description: Security schemes should be defined in components.
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  error-schema-defined:
    description: A shared error schema (Error) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: Error
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy