Amazon Cognito · API Governance Rules

Amazon Cognito API Rules

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

28 Rules error 10 warn 15 info 3
View Rules File View on GitHub

Rule Categories

cognito error get info microcks no openapi operation parameter query request response schema security servers

Rules

error
info-title-required
OpenAPI info must have a title.
$.info
warn
info-description-required
OpenAPI info must have a description with at least 20 characters.
$.info
error
info-version-required
OpenAPI info must have a version field.
$.info
error
openapi-version-3
Specs must use OpenAPI 3.0.x.
$
error
servers-required
At least one server must be defined.
$
warn
servers-https-required
Server URLs must use HTTPS.
$.servers[*]
error
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-summary-amazon-prefix
Operation summaries should start with "Amazon Cognito".
$.paths[*][get,post,put,patch,delete,head,options].summary
warn
operation-description-required
Every operation must have a description.
$.paths[*][get,post,put,patch,delete,head,options]
error
operation-id-required
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-id-pascal-case
OperationIds should use PascalCase as per AWS convention.
$.paths[*][get,post,put,patch,delete,head,options].operationId
warn
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete,head,options]
warn
parameter-description-required
Every parameter must have a description.
$.paths[*][get,post,put,patch,delete,head,options].parameters[*]
error
parameter-schema-required
Every parameter must have a schema.
$.paths[*][get,post,put,patch,delete,head,options].parameters[*]
warn
request-body-json-content
Request bodies should use application/json content type.
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
Every operation must define responses.
$.paths[*][get,post,put,patch,delete]
warn
response-description-required
Every response must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
info
schema-description-recommended
Top-level schemas should have a description.
$.components.schemas[*]
warn
schema-type-defined
Schema objects should have a type defined.
$.components.schemas[*]
error
security-schemes-defined
Security schemes must be defined in components.
$.components
error
get-no-request-body
GET operations should not have a request body.
$.paths[*].get
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description
info
microcks-operation-extension
Operations should have x-microcks-operation for mock server compatibility.
$.paths[*][get,post,put,patch,delete]
info
cognito-scopes-documented
OAuth scopes used by Cognito User Pools should be documented in security schemes.
$.components.securitySchemes[*]
warn
query-params-casing
Query parameters should be PascalCase (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
warn
schema-properties-casing
Schema properties should be PascalCase (the dominant convention in this API).
$.components.schemas[*].properties
warn
error-schema-defined
A shared error schema (InternalErrorException) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# amazon-cognito — 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: 50% of servers already https (warn)
#   - query-params-casing: pascal @ 100% (n=20)
#   - operationid-casing: pascal @ 100% (n=126)
#   - schema-names-casing: pascal @ 100% (n=585)
#   - schema-properties-casing: pascal @ 100% (n=931)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: InternalErrorException
#   - merge: kept 24 existing, added 4 measured, upgraded 0
#   - added: query-params-casing, schema-names-casing, schema-properties-casing, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-required:
    description: OpenAPI info must have a title.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-description-required:
    description: OpenAPI info must have a description with at least 20 characters.
    severity: warn
    given: $.info
    then:
      field: description
      function: minLength
      functionOptions:
        min: 20
  info-version-required:
    description: OpenAPI info must have a version field.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  openapi-version-3:
    description: Specs must use OpenAPI 3.0.x.
    severity: error
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.0\.
  servers-required:
    description: At least one server must be defined.
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https-required:
    description: Server URLs must use HTTPS.
    severity: warn
    given: $.servers[*]
    then:
      field: url
      function: pattern
      functionOptions:
        match: ^https://
  operation-summary-required:
    description: Every operation must have a summary.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: summary
      function: truthy
  operation-summary-amazon-prefix:
    description: Operation summaries should start with "Amazon Cognito".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options].summary
    then:
      function: pattern
      functionOptions:
        match: ^Amazon Cognito
  operation-description-required:
    description: Every operation must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: description
      function: truthy
  operation-id-required:
    description: Every operation must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: operationId
      function: truthy
  operation-id-pascal-case:
    description: OperationIds should use PascalCase as per AWS convention.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][a-zA-Z0-9]*$
  operation-tags-required:
    description: Every operation must have at least one tag.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: tags
      function: truthy
  parameter-description-required:
    description: Every parameter must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options].parameters[*]
    then:
      field: description
      function: truthy
  parameter-schema-required:
    description: Every parameter must have a schema.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options].parameters[*]
    then:
      field: schema
      function: truthy
  request-body-json-content:
    description: Request bodies should use application/json content type.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      field: application/json
      function: truthy
  response-success-required:
    description: Every operation must define responses.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: responses
      function: truthy
  response-description-required:
    description: Every response must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy
  schema-description-recommended:
    description: Top-level schemas should have a description.
    severity: info
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  schema-type-defined:
    description: Schema objects should have a type defined.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy
  security-schemes-defined:
    description: Security schemes must be defined in components.
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  get-no-request-body:
    description: GET operations should 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: truthy
  microcks-operation-extension:
    description: Operations should have x-microcks-operation for mock server compatibility.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: x-microcks-operation
      function: truthy
  cognito-scopes-documented:
    description: OAuth scopes used by Cognito User Pools should be documented in security schemes.
    severity: info
    given: $.components.securitySchemes[*]
    then:
      field: description
      function: truthy
  query-params-casing:
    description: Query parameters should be PascalCase (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: 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: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*$
  schema-properties-casing:
    description: Schema properties should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*$
  error-schema-defined:
    description: A shared error schema (InternalErrorException) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: InternalErrorException
      function: truthy