Shovels · API Governance Rules

Shovels API Rules

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

10 Rules error 5 warn 5
View Rules File View on GitHub

Rule Categories

shovels

Rules

error
shovels-operation-tags
All operations must have at least one tag
$.paths[*][*]
error
shovels-operation-summary
All operations must have a summary in Title Case
$.paths[*][*]
error
shovels-api-key-auth
API must use X-API-Key header authentication
$.components.securitySchemes[*]
warn
shovels-geo-id-parameter
Geographic search endpoints must include geo_id parameter
$.paths[*].get.parameters[?(@.name == 'geo_id')]
warn
shovels-cursor-pagination
List endpoints should support cursor-based pagination
$.paths[*].get.parameters[?(@.name == 'cursor')]
warn
shovels-date-format
Date parameters must use YYYY-MM-DD format
$.paths[*].get.parameters[?(@.schema.format == 'date')]
error
shovels-response-200
All GET operations must have a 200 response
$.paths[*].get.responses
warn
shovels-response-422
Operations with required parameters should document 422 validation errors
$.paths[*].get.responses
error
shovels-items-schema
List response schemas should have items array property
$.components.schemas[*Response]
warn
shovels-geo-id-field
Geographic schemas should include geo_id field
$.components.schemas[*]

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  shovels-operation-tags:
    description: All operations must have at least one tag
    message: "Operation '{{property}}' must have at least one tag"
    given: "$.paths[*][*]"
    severity: error
    then:
      field: tags
      function: truthy

  shovels-operation-summary:
    description: All operations must have a summary in Title Case
    message: "Operation must have a summary"
    given: "$.paths[*][*]"
    severity: error
    then:
      field: summary
      function: truthy

  shovels-api-key-auth:
    description: API must use X-API-Key header authentication
    message: "Security scheme must be apiKey in header named X-API-Key"
    given: "$.components.securitySchemes[*]"
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            type:
              enum: [apiKey]
            in:
              enum: [header]
            name:
              enum: [X-API-Key]

  shovels-geo-id-parameter:
    description: Geographic search endpoints must include geo_id parameter
    message: "Search endpoints for geographic data should document geo_id parameter"
    given: "$.paths[*].get.parameters[?(@.name == 'geo_id')]"
    severity: warn
    then:
      field: description
      function: truthy

  shovels-cursor-pagination:
    description: List endpoints should support cursor-based pagination
    message: "List endpoints should have cursor pagination parameter"
    given: "$.paths[*].get.parameters[?(@.name == 'cursor')]"
    severity: warn
    then:
      field: schema
      function: truthy

  shovels-date-format:
    description: Date parameters must use YYYY-MM-DD format
    message: "Date parameters must specify format: date"
    given: "$.paths[*].get.parameters[?(@.schema.format == 'date')]"
    severity: warn
    then:
      field: description
      function: truthy

  shovels-response-200:
    description: All GET operations must have a 200 response
    message: "GET operation must define a 200 response"
    given: "$.paths[*].get.responses"
    severity: error
    then:
      field: "200"
      function: truthy

  shovels-response-422:
    description: Operations with required parameters should document 422 validation errors
    message: "Operations should document 422 validation error responses"
    given: "$.paths[*].get.responses"
    severity: warn
    then:
      field: "422"
      function: defined

  shovels-items-schema:
    description: List response schemas should have items array property
    message: "List response must include items array"
    given: "$.components.schemas[*Response]"
    severity: error
    then:
      field: properties.items
      function: truthy

  shovels-geo-id-field:
    description: Geographic schemas should include geo_id field
    message: "Geographic schemas should include geo_id identifier field"
    given: "$.components.schemas[*]"
    severity: warn
    then:
      function: defined