Allianz Technology Standards · API Governance Rules

Allianz Technology Standards API Rules

Spectral linting rules defining API design standards and conventions for Allianz Technology Standards.

22 Rules error 14 warn 7 info 1
View Rules File View on GitHub

Rule Categories

async get global info list oauth2 openapi operation parameter paths response security servers tags

Rules

warn
info-title-allianz-prefix
API title must start with "Allianz"
$.info.title
error
info-description-required
API info must have a description
$.info
error
info-version-required
API info must define a version
$.info
error
openapi-version-3
Specs must use OpenAPI 3.x (API-first standard)
$.openapi
error
servers-defined
At least one server must be defined
$
error
servers-https
Server URLs must use HTTPS (Allianz security standard)
$.servers[*].url
error
paths-no-trailing-slash
Paths must not have trailing slashes
$.paths
error
operation-summary-required
Every operation must have a summary
$.paths[*][get,post,put,patch,delete]
error
operation-description-required
Every operation must have a description
$.paths[*][get,post,put,patch,delete]
error
operation-id-required
Every operation must have an operationId
$.paths[*][get,post,put,patch,delete]
error
operation-tags-required
Every operation must have at least one tag
$.paths[*][get,post,put,patch,delete]
warn
list-operations-page-size
List operations should support pageSize query parameter (Allianz pagination standard)
$.paths[*].get.parameters[*].name
warn
list-operations-page-param
List operations should support page query parameter (Allianz pagination standard)
$.paths[*].get.parameters[*].name
info
async-post-returns-202
Async POST operations should return 202 Accepted (Allianz async pattern)
$.paths[*].post.responses
error
security-schemes-defined
Security schemes must be defined (OAuth2 standard)
$.components
warn
oauth2-scheme-required
OAuth2 security scheme should be defined (Allianz OAuth2 standard)
$.components.securitySchemes
warn
global-security-defined
Global security should be defined
$
error
get-no-request-body
GET operations must not have request bodies
$.paths[*].get
error
response-description-required
All responses must have descriptions
$.paths[*][get,post,put,patch,delete].responses[*]
warn
response-401-required
Operations should define a 401 response
$.paths[*][get,post,put,patch,delete].responses
warn
tags-defined
Global tags array should be defined
$
error
parameter-description-required
All parameters must have descriptions
$.paths[*][get,post,put,patch,delete].parameters[*]

Spectral Ruleset

allianz-technology-standards-spectral-rules.yml Raw ↑
# Allianz Technology Standards Spectral Rules
# Enforces Allianz API design conventions based on the technology standards documentation

rules:

  info-title-allianz-prefix:
    description: API title must start with "Allianz"
    severity: warn
    given: "$.info.title"
    then:
      function: pattern
      functionOptions:
        match: "^Allianz"

  info-description-required:
    description: API info must have a description
    severity: error
    given: "$.info"
    then:
      field: description
      function: truthy

  info-version-required:
    description: API info must define a version
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy

  openapi-version-3:
    description: Specs must use OpenAPI 3.x (API-first standard)
    severity: error
    given: "$.openapi"
    then:
      function: pattern
      functionOptions:
        match: "^3\\."

  servers-defined:
    description: At least one server must be defined
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

  servers-https:
    description: Server URLs must use HTTPS (Allianz security standard)
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  paths-no-trailing-slash:
    description: Paths must not have trailing slashes
    severity: error
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        notMatch: "\\/$"

  operation-summary-required:
    description: Every operation must have a summary
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  operation-description-required:
    description: Every operation must have a description
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  operation-id-required:
    description: Every operation must have an operationId
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  operation-tags-required:
    description: Every operation must have at least one tag
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  # ALLIANZ PAGINATION STANDARD
  list-operations-page-size:
    description: List operations should support pageSize query parameter (Allianz pagination standard)
    severity: warn
    given: "$.paths[*].get.parameters[*].name"
    then:
      function: pattern
      functionOptions:
        match: "^(pageSize|page_size|limit)$"

  list-operations-page-param:
    description: List operations should support page query parameter (Allianz pagination standard)
    severity: warn
    given: "$.paths[*].get.parameters[*].name"
    then:
      function: pattern
      functionOptions:
        match: "^(page|offset)$"

  # ALLIANZ ASYNC PATTERN
  async-post-returns-202:
    description: Async POST operations should return 202 Accepted (Allianz async pattern)
    severity: info
    given: "$.paths[*].post.responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  # SECURITY
  security-schemes-defined:
    description: Security schemes must be defined (OAuth2 standard)
    severity: error
    given: "$.components"
    then:
      field: securitySchemes
      function: truthy

  oauth2-scheme-required:
    description: OAuth2 security scheme should be defined (Allianz OAuth2 standard)
    severity: warn
    given: "$.components.securitySchemes"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - OAuth2

  global-security-defined:
    description: Global security should be defined
    severity: warn
    given: "$"
    then:
      field: security
      function: truthy

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

  # RESPONSE STANDARDS
  response-description-required:
    description: All responses must have descriptions
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses[*]"
    then:
      field: description
      function: truthy

  response-401-required:
    description: Operations should define a 401 response
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - "401"

  # TAGS
  tags-defined:
    description: Global tags array should be defined
    severity: warn
    given: "$"
    then:
      field: tags
      function: truthy

  # PARAMETER STANDARDS
  parameter-description-required:
    description: All parameters must have descriptions
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].parameters[*]"
    then:
      field: description
      function: truthy