Amazon Cognito · API Governance Rules

Amazon Cognito API Rules

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

24 Rules error 10 warn 11 info 3
View Rules File View on GitHub

Rule Categories

cognito get info microcks no openapi operation parameter 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[*]

Spectral Ruleset

Raw ↑
rules:
  # INFO / METADATA
  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
  openapi-version-3:
    description: Specs must use OpenAPI 3.0.x.
    severity: error
    given: "$"
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: "^3\\.0\\."

  # SERVERS
  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://"

  # OPERATIONS
  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

  # PARAMETERS
  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 BODIES
  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

  # RESPONSES
  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

  # SCHEMAS
  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
  security-schemes-defined:
    description: Security schemes must be defined in components.
    severity: error
    given: "$.components"
    then:
      field: securitySchemes
      function: truthy

  # HTTP METHOD CONVENTIONS
  get-no-request-body:
    description: GET operations should not have a request body.
    severity: error
    given: "$.paths[*].get"
    then:
      field: requestBody
      function: falsy

  # GENERAL QUALITY
  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