Allianz Future Cloud Platform · API Governance Rules

Allianz Future Cloud Platform API Rules

Spectral linting rules defining API design standards and conventions for Allianz Future Cloud Platform.

24 Rules error 15 warn 6 info 3
View Rules File View on GitHub

Rule Categories

async get info openapi operation parameter paths response schema 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
$.openapi
error
servers-defined
At least one server must be defined
$
error
servers-https
Server URLs must use HTTPS
$.servers[*].url
warn
paths-kebab-case
Path segments must use kebab-case
$.paths
info
paths-versioned
API paths should be prefixed with /api or contain versioning
$.paths
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]
warn
operation-summary-allianz-prefix
Summaries must start with "Allianz Future Cloud Platform"
$.paths[*][get,post,put,patch,delete].summary
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]
warn
operation-id-camel-case
operationId must use camelCase
$.paths[*][get,post,put,patch,delete].operationId
error
operation-tags-required
Every operation must have at least one tag
$.paths[*][get,post,put,patch,delete]
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[*]
error
response-success-required
Every operation must define a success response
$.paths[*][get,post,put,patch,delete]
warn
response-401-required
Operations should define a 401 response
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
All responses must have descriptions
$.paths[*][get,post,put,patch,delete].responses[*]
error
security-schemes-defined
Security schemes must be defined
$.components
error
get-no-request-body
GET operations must not have request bodies
$.paths[*].get
info
schema-properties-described
Schema properties should have descriptions
$.components.schemas[*].properties[*]
info
async-operations-return-202
Async operations should return 202 Accepted
$.paths[*].post.operationId

Spectral Ruleset

Raw ↑
# Allianz Future Cloud Platform Spectral Rules
# Enforces API conventions for the Allianz Future Cloud Platform Services API

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
    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
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  paths-kebab-case:
    description: Path segments must use kebab-case
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^(\\/([a-z0-9][a-z0-9-]*|\\{[a-zA-Z_]+\\}))+$"

  paths-versioned:
    description: API paths should be prefixed with /api or contain versioning
    severity: info
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^\\/[a-z]"

  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-summary-allianz-prefix:
    description: Summaries must start with "Allianz Future Cloud Platform"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^Allianz Future Cloud Platform"

  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-id-camel-case:
    description: operationId must use camelCase
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].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: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

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

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

  response-success-required:
    description: Every operation must define a success response
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: responses
      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"

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

  security-schemes-defined:
    description: Security schemes must be defined
    severity: error
    given: "$.components"
    then:
      field: securitySchemes
      function: truthy

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

  schema-properties-described:
    description: Schema properties should have descriptions
    severity: info
    given: "$.components.schemas[*].properties[*]"
    then:
      field: description
      function: truthy

  async-operations-return-202:
    description: Async operations should return 202 Accepted
    severity: info
    given: "$.paths[*].post.operationId"
    then:
      function: pattern
      functionOptions:
        match: "^(deploy|provision|register)"