Clearstream · API Governance Rules

Clearstream API Rules

Spectral linting rules defining API design standards and conventions for Clearstream.

11 Rules error 3 warn 8
View Rules File View on GitHub

Rule Categories

clearstream

Rules

error
clearstream-info-contact
API contact information must be present.
$.info
warn
clearstream-info-license
API license must be declared.
$.info
warn
clearstream-info-iso-version
Info description should reference ISO 15022 or ISO 20022.
$.info.description
error
clearstream-server-https
All server URLs must use HTTPS.
$.servers[*].url
warn
clearstream-server-domain
Server URLs must point at a clearstream.com host.
$.servers[*].url
warn
clearstream-operation-tags
Every operation must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
clearstream-operation-summary
Every operation must include a short summary.
$.paths[*][get,post,put,patch,delete]
error
clearstream-operation-id
Every operation must declare a unique operationId.
$.paths[*][get,post,put,patch,delete]
warn
clearstream-error-responses
Mutating operations should declare 4xx error responses.
$.paths[*][post,put,patch,delete].responses
warn
clearstream-bic-format
Counterparty BIC parameters should be 8 or 11 character ISO 9362 BICs.
$.paths[*][*].parameters[?(@.name && @.name.match(/bic/i))].schema
warn
clearstream-isin-format
ISIN parameters should be 12-character ISO 6166 identifiers.
$.paths[*][*].parameters[?(@.name && @.name.match(/isin/i))].schema

Spectral Ruleset

clearstream-rules.yml Raw ↑
extends:
  - spectral:oas

# Spectral linting rules tuned for Clearstream connectivity.
# Clearstream's developer surface is largely message-based (SWIFT FIN/FileAct,
# ISO 15022 MT and ISO 20022 MX), so these rules focus on the descriptive
# OpenAPI / AsyncAPI overlays that catalogue those channels rather than a
# public REST API.
rules:
  clearstream-info-contact:
    description: API contact information must be present.
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

  clearstream-info-license:
    description: API license must be declared.
    severity: warn
    given: "$.info"
    then:
      field: license
      function: truthy

  clearstream-info-iso-version:
    description: Info description should reference ISO 15022 or ISO 20022.
    severity: warn
    given: "$.info.description"
    then:
      function: pattern
      functionOptions:
        match: "ISO\\s?(15022|20022)"

  clearstream-server-https:
    description: All server URLs must use HTTPS.
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  clearstream-server-domain:
    description: Server URLs must point at a clearstream.com host.
    severity: warn
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "clearstream\\.com"

  clearstream-operation-tags:
    description: Every operation must declare at least one tag.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 1

  clearstream-operation-summary:
    description: Every operation must include a short summary.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

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

  clearstream-error-responses:
    description: Mutating operations should declare 4xx error responses.
    severity: warn
    given: "$.paths[*][post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ["400"]
            - required: ["401"]
            - required: ["403"]
            - required: ["404"]
            - required: ["422"]

  clearstream-bic-format:
    description: Counterparty BIC parameters should be 8 or 11 character ISO 9362 BICs.
    severity: warn
    given: "$.paths[*][*].parameters[?(@.name && @.name.match(/bic/i))].schema"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            pattern:
              type: string
              enum:
                - "^[A-Z0-9]{8}([A-Z0-9]{3})?$"

  clearstream-isin-format:
    description: ISIN parameters should be 12-character ISO 6166 identifiers.
    severity: warn
    given: "$.paths[*][*].parameters[?(@.name && @.name.match(/isin/i))].schema"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            pattern:
              type: string
              enum:
                - "^[A-Z]{2}[A-Z0-9]{9}\\d$"