The Racing API · API Governance Rules

The Racing API API Rules

Spectral linting rules defining API design standards and conventions for The Racing API.

35 Rules error 9 warn 17 info 9
View Rules File View on GitHub

Rule Categories

error get info no openapi operation parameter path paths query response schema security servers

Rules

error
info-title-required
Info object must have a title
$.info
warn
info-description-required
Info object must have a description with minimum length
$.info
error
info-version-required
API version must be defined
$.info
warn
openapi-version-31
OpenAPI version should be 3.1.x
$
error
servers-defined
Servers array must be defined and non-empty
$
error
servers-https
Server URLs must use HTTPS
$.servers[*].url
warn
paths-kebab-case
Path segments must use kebab-case
$.paths[*]~
warn
paths-no-trailing-slash
Paths must not have trailing slashes
$.paths[*]~
info
paths-versioned
Paths should include version prefix /v1/
$.paths[*]~
error
operation-summary-required
Operations must have a summary
$.paths[*][get,post,put,delete,patch]
warn
operation-description-required
Operations must have a description
$.paths[*][get,post,put,delete,patch]
error
operation-operationId-required
Operations must have an operationId
$.paths[*][get,post,put,delete,patch]
warn
operation-tags-required
Operations must have at least one tag
$.paths[*][get,post,put,delete,patch]
info
operation-summary-provider-prefix
Operation summaries should start with 'The Racing API'
$.paths[*][get,post,put,delete,patch].summary
warn
parameter-description-required
Parameters must have descriptions
$.paths[*][get,post,put,delete,patch].parameters[*]
info
parameter-snake-case
Query parameter names should use snake_case
$.paths[*][get,post,put,delete,patch].parameters[?(@.in=='query')].name
warn
parameter-apikey-not-in-query
API keys should be in headers not query parameters
$.paths[*][get,post,put,delete,patch].parameters[?(@.name=='api_key' || @.name=='apikey')]
error
response-success-required
Operations must have at least one 2xx response
$.paths[*][get,post,put,delete,patch].responses
warn
response-description-required
Response objects must have a description
$.paths[*][get,post,put,delete,patch].responses[*]
info
response-404-for-id-paths
Endpoints with path parameters should have a 404 response
$.paths[~*{*}*][get].responses
info
response-422-validation-error
The Racing API uses 422 for validation errors
$.paths[*][get,post,put,delete,patch].responses
warn
schema-type-defined
Schema objects should have a type defined
$.components.schemas[*]
info
schema-description-required
Top-level schemas should have a description
$.components.schemas[*]
error
security-schemes-defined
Security schemes must be defined in components
$.components
info
security-basic-auth
The Racing API uses HTTP Basic authentication
$.components.securitySchemes[*]
error
get-no-request-body
GET operations must not have a request body
$.paths[*].get
warn
no-empty-descriptions
Descriptions must not be empty strings
$..description
info
operation-examples-encouraged
Operations should have examples for mock server compatibility
$.paths[*][get,post,put,delete,patch].responses[*].content[*]
warn
servers-expected-domain
Server URLs should be on the theracingapi.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
warn
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
operation-security-required
Every operation should declare its security requirements.
$.paths[*][get,post,put,patch,delete]
warn
error-schema-defined
A shared error schema (HTTPValidationError) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# the-racing-api — 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: 1/1 servers on theracingapi.com
#   - path-params-casing: snake @ 100% (n=40)
#   - query-params-casing: snake @ 100% (n=385)
#   - schema-names-casing: pascal @ 67% (n=124)
#   - schema-properties-casing: snake @ 89% (n=1223)
#   - operation-security-required: 58/58 ops declare per-op security
#   - error-schema-defined: HTTPValidationError
#   - operation-documents-404: 100% adherence
#   - pagination params observed: ['limit']
#   - merge: kept 28 existing, added 7 measured, upgraded 0
#   - added: servers-expected-domain, path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, operation-security-required, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-required:
    description: Info object must have a title
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-description-required:
    description: Info object must have a description with minimum length
    severity: warn
    given: $.info
    then:
      field: description
      function: minLength
      functionOptions:
        value: 20
  info-version-required:
    description: API version must be defined
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  openapi-version-31:
    description: OpenAPI version should be 3.1.x
    severity: warn
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.1\.
  servers-defined:
    description: Servers array must be defined and non-empty
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https:
    description: Server URLs must use HTTPS
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  paths-kebab-case:
    description: Path segments must use kebab-case
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/v[0-9]+)?(/[a-z0-9]+(-[a-z0-9]+)*(/{[a-z_]+})?)*$
  paths-no-trailing-slash:
    description: Paths must not have trailing slashes
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: /$
  paths-versioned:
    description: Paths should include version prefix /v1/
    severity: info
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^/v[0-9]
  operation-summary-required:
    description: Operations must have a summary
    severity: error
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: summary
      function: truthy
  operation-description-required:
    description: Operations must have a description
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: description
      function: truthy
  operation-operationId-required:
    description: Operations must have an operationId
    severity: error
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: operationId
      function: truthy
  operation-tags-required:
    description: Operations must have at least one tag
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: tags
      function: truthy
  operation-summary-provider-prefix:
    description: Operation summaries should start with 'The Racing API'
    severity: info
    given: $.paths[*][get,post,put,delete,patch].summary
    then:
      function: pattern
      functionOptions:
        match: '^The Racing API '
  parameter-description-required:
    description: Parameters must have descriptions
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].parameters[*]
    then:
      field: description
      function: truthy
  parameter-snake-case:
    description: Query parameter names should use snake_case
    severity: info
    given: $.paths[*][get,post,put,delete,patch].parameters[?(@.in=='query')].name
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  parameter-apikey-not-in-query:
    description: API keys should be in headers not query parameters
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].parameters[?(@.name=='api_key' || @.name=='apikey')]
    then:
      field: in
      function: enumeration
      functionOptions:
        values:
        - header
  response-success-required:
    description: Operations must have at least one 2xx response
    severity: error
    given: $.paths[*][get,post,put,delete,patch].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1
  response-description-required:
    description: Response objects must have a description
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].responses[*]
    then:
      field: description
      function: truthy
  response-404-for-id-paths:
    description: Endpoints with path parameters should have a 404 response
    severity: info
    given: $.paths[~*{*}*][get].responses
    then:
      field: '404'
      function: truthy
  response-422-validation-error:
    description: The Racing API uses 422 for validation errors
    severity: info
    given: $.paths[*][get,post,put,delete,patch].responses
    then:
      field: '422'
      function: defined
  schema-type-defined:
    description: Schema objects should have a type defined
    severity: warn
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy
  schema-description-required:
    description: Top-level schemas should have a description
    severity: info
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  security-schemes-defined:
    description: Security schemes must be defined in components
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  security-basic-auth:
    description: The Racing API uses HTTP Basic authentication
    severity: info
    given: $.components.securitySchemes[*]
    then:
      field: type
      function: enumeration
      functionOptions:
        values:
        - http
  get-no-request-body:
    description: GET operations must not have a request body
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  no-empty-descriptions:
    description: Descriptions must not be empty strings
    severity: warn
    given: $..description
    then:
      function: pattern
      functionOptions:
        match: .+
  operation-examples-encouraged:
    description: Operations should have examples for mock server compatibility
    severity: info
    given: $.paths[*][get,post,put,delete,patch].responses[*].content[*]
    then:
      field: examples
      function: defined
  servers-expected-domain:
    description: Server URLs should be on the theracingapi.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: theracingapi\.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: warn
    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: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*$
  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
  operation-security-required:
    description: Every operation should declare its security requirements.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: security
      function: truthy
  error-schema-defined:
    description: A shared error schema (HTTPValidationError) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: HTTPValidationError
      function: truthy