Amazon API Gateway · API Governance Rules

Amazon API Gateway API Rules

Spectral linting rules defining API design standards and conventions for Amazon API Gateway.

17 Rules error 5 warn 10 info 2
View Rules File View on GitHub

Rule Categories

amazon error no operation operationid path query schema security servers

Rules

error
amazon-info-title-required
API must have a title.
$.info
error
amazon-operation-summary-required
Operations must have summaries.
$.paths[*][get,post,put,patch,delete]
error
amazon-operation-operationid-required
Operations must have operationIds.
$.paths[*][get,post,put,patch,delete]
error
amazon-response-200-get
GET operations must return 200.
$.paths[*].get
info
amazon-schema-description
Schemas should have descriptions.
$.components.schemas[*]
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-expected-domain
Server URLs should be on the amazonaws.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
operationid-casing
Operation IDs should be PascalCase (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].operationId
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 camelCase (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
operation-documents-404
Operations should document a 404 response (documented on 84% of this API's operations).
$.paths[*][get,post,put,patch,delete].responses
warn
operation-documents-429
Operations should document a 429 response (documented on 100% of this API's operations).
$.paths[*][get,post,put,patch,delete].responses
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# amazon-api-gateway — 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 amazonaws.com
#   - path-params-casing: snake @ 100% (n=174)
#   - query-params-casing: snake @ 83% (n=82)
#   - operationid-casing: pascal @ 100% (n=134)
#   - schema-names-casing: pascal @ 100% (n=126)
#   - schema-properties-casing: camel @ 60% (n=644)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: Error
#   - operation-documents-404: 84% adherence
#   - operation-documents-429: 100% adherence
#   - pagination params observed: ['limit']
#   - merge: kept 5 existing, added 12 measured, upgraded 0
#   - added: servers-https-only, servers-expected-domain, path-params-casing, query-params-casing, operationid-casing, schema-names-casing, schema-properties-casing, security-schemes-defined, error-schema-defined, operation-documents-404, operation-documents-429, no-empty-descriptions
extends:
  - spectral:oas
rules:
  amazon-info-title-required:
    description: API must have a title.
    message: Info must include title.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  amazon-operation-summary-required:
    description: Operations must have summaries.
    message: Operation must include summary.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  amazon-operation-operationid-required:
    description: Operations must have operationIds.
    message: Operation must include operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  amazon-response-200-get:
    description: GET operations must return 200.
    message: GET must have 200 response.
    severity: error
    given: $.paths[*].get
    then:
      field: responses.200
      function: truthy
  amazon-schema-description:
    description: Schemas should have descriptions.
    message: Schema should include description.
    severity: info
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  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 amazonaws.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: amazonaws\.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
  operationid-casing:
    description: Operation IDs should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: casing
      functionOptions:
        type: pascal
  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 camelCase (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^[a-z][A-Za-z0-9]*$
  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
  operation-documents-404:
    description: Operations should document a 404 response (documented on 84% of this API's operations).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '404'
      function: truthy
  operation-documents-429:
    description: Operations should document a 429 response (documented on 100% of this API's operations).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '429'
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy