Allianz Trade · API Governance Rules

Allianz Trade API Rules

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

22 Rules error 5 warn 14 info 3
View Rules File View on GitHub

Rule Categories

allianz

Rules

warn
allianz-trade-operation-summary-prefix
All operation summaries must start with "Allianz Trade"
$.paths[*][*].summary
error
allianz-trade-operation-tags
All operations must have at least one tag
$.paths[*][*]
error
allianz-trade-operation-id
All operations must have an operationId
$.paths[*][*]
warn
allianz-trade-operation-description
All operations must have a description
$.paths[*][*]
warn
allianz-trade-pagination-page-size
List operations must support pageSize query parameter
$.paths[*].get
warn
allianz-trade-pagination-page
List operations must support page query parameter
$.paths[*].get
warn
allianz-trade-pagination-total-required
List operations must support totalRequired query parameter
$.paths[*].get
warn
allianz-trade-async-202
Write operations (POST/PATCH/DELETE) must return 202 for async processing
$.paths[*][post,patch,delete]
warn
allianz-trade-async-job-response
202 responses must reference JobResponse schema
$.paths[*][post,patch,delete].responses.202.content.application/json.schema.$ref
error
allianz-trade-error-response-401
All operations must document 401 Unauthorized response
$.paths[*][*].responses
warn
allianz-trade-error-schema-code
ErrorResponse must have a code property
$.components.schemas.ErrorResponse.properties
warn
allianz-trade-error-schema-message
ErrorResponse must have a message property
$.components.schemas.ErrorResponse.properties
error
allianz-trade-oauth2-security
API must use OAuth2 security scheme
$.components.securitySchemes
error
allianz-trade-oauth2-client-credentials
OAuth2 must use client credentials flow
$.components.securitySchemes.OAuth2.flows
warn
allianz-trade-schema-title
All schemas must have a title
$.components.schemas[*]
warn
allianz-trade-schema-description
All schemas must have a description
$.components.schemas[*]
warn
allianz-trade-property-description
All schema properties must have a description
$.components.schemas[*].properties[*]
info
allianz-trade-property-example
Schema properties should have examples
$.components.schemas[*].properties[*]
info
allianz-trade-microcks-operation
All operations should have x-microcks-operation extension
$.paths[*][*]
info
allianz-trade-id-pattern
Identifier fields should follow Allianz Trade ID pattern (PREFIX-NNNNNN)
$.components.schemas[*].properties[?(@property.endsWith('Id'))].example
warn
allianz-trade-currency-iso
Currency properties must use ISO 4217 format
$.components.schemas[*].properties.currency.description
warn
allianz-trade-date-format
Date properties must specify date format
$.components.schemas[*].properties[?(@property.endsWith('Date') || @property.endsWith('date'))].format

Spectral Ruleset

Raw ↑
rules:
  allianz-trade-operation-summary-prefix:
    description: All operation summaries must start with "Allianz Trade"
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^Allianz Trade"

  allianz-trade-operation-tags:
    description: All operations must have at least one tag
    severity: error
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  allianz-trade-operation-id:
    description: All operations must have an operationId
    severity: error
    given: "$.paths[*][*]"
    then:
      field: operationId
      function: truthy

  allianz-trade-operation-description:
    description: All operations must have a description
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: description
      function: truthy

  allianz-trade-pagination-page-size:
    description: List operations must support pageSize query parameter
    severity: warn
    given: "$.paths[*].get"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            parameters:
              type: array
              contains:
                type: object
                properties:
                  name:
                    const: pageSize

  allianz-trade-pagination-page:
    description: List operations must support page query parameter
    severity: warn
    given: "$.paths[*].get"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            parameters:
              type: array
              contains:
                type: object
                properties:
                  name:
                    const: page

  allianz-trade-pagination-total-required:
    description: List operations must support totalRequired query parameter
    severity: warn
    given: "$.paths[*].get"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            parameters:
              type: array
              contains:
                type: object
                properties:
                  name:
                    const: totalRequired

  allianz-trade-async-202:
    description: Write operations (POST/PATCH/DELETE) must return 202 for async processing
    severity: warn
    given: "$.paths[*][post,patch,delete]"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            responses:
              type: object
              required:
                - "202"

  allianz-trade-async-job-response:
    description: 202 responses must reference JobResponse schema
    severity: warn
    given: "$.paths[*][post,patch,delete].responses.202.content.application/json.schema.$ref"
    then:
      function: pattern
      functionOptions:
        match: "JobResponse"

  allianz-trade-error-response-401:
    description: All operations must document 401 Unauthorized response
    severity: error
    given: "$.paths[*][*].responses"
    then:
      field: "401"
      function: truthy

  allianz-trade-error-schema-code:
    description: ErrorResponse must have a code property
    severity: warn
    given: "$.components.schemas.ErrorResponse.properties"
    then:
      field: code
      function: truthy

  allianz-trade-error-schema-message:
    description: ErrorResponse must have a message property
    severity: warn
    given: "$.components.schemas.ErrorResponse.properties"
    then:
      field: message
      function: truthy

  allianz-trade-oauth2-security:
    description: API must use OAuth2 security scheme
    severity: error
    given: "$.components.securitySchemes"
    then:
      field: OAuth2
      function: truthy

  allianz-trade-oauth2-client-credentials:
    description: OAuth2 must use client credentials flow
    severity: error
    given: "$.components.securitySchemes.OAuth2.flows"
    then:
      field: clientCredentials
      function: truthy

  allianz-trade-schema-title:
    description: All schemas must have a title
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: title
      function: truthy

  allianz-trade-schema-description:
    description: All schemas must have a description
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy

  allianz-trade-property-description:
    description: All schema properties must have a description
    severity: warn
    given: "$.components.schemas[*].properties[*]"
    then:
      field: description
      function: truthy

  allianz-trade-property-example:
    description: Schema properties should have examples
    severity: info
    given: "$.components.schemas[*].properties[*]"
    then:
      field: example
      function: truthy

  allianz-trade-microcks-operation:
    description: All operations should have x-microcks-operation extension
    severity: info
    given: "$.paths[*][*]"
    then:
      field: x-microcks-operation
      function: truthy

  allianz-trade-id-pattern:
    description: Identifier fields should follow Allianz Trade ID pattern (PREFIX-NNNNNN)
    severity: info
    given: "$.components.schemas[*].properties[?(@property.endsWith('Id'))].example"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z]+-[0-9]+$"

  allianz-trade-currency-iso:
    description: Currency properties must use ISO 4217 format
    severity: warn
    given: "$.components.schemas[*].properties.currency.description"
    then:
      function: pattern
      functionOptions:
        match: "ISO 4217"

  allianz-trade-date-format:
    description: Date properties must specify date format
    severity: warn
    given: "$.components.schemas[*].properties[?(@property.endsWith('Date') || @property.endsWith('date'))].format"
    then:
      function: enumeration
      functionOptions:
        values:
          - date
          - date-time