CloudHealth · API Governance Rules

CloudHealth API Rules

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

10 Rules error 4 warn 6
View Rules File View on GitHub

Rule Categories

cloudhealth

Rules

error
cloudhealth-info-contact
API contact information must be present.
$.info
warn
cloudhealth-info-license
API license must be declared.
$.info
error
cloudhealth-server-https
All server URLs must use HTTPS for the chapi.cloudhealthtech.com control plane.
$.servers[*].url
warn
cloudhealth-server-host
Server URLs should target chapi.cloudhealthtech.com.
$.servers[*].url
warn
cloudhealth-versioned-paths
CloudHealth REST API paths should be versioned (/v{N}/) where applicable.
$.paths
error
cloudhealth-auth-required
A bearer security scheme must be declared.
$.components.securitySchemes
error
cloudhealth-operation-id
Every operation must declare a unique operationId.
$.paths[*][get,post,put,patch,delete]
warn
cloudhealth-operation-tags
Every operation must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
cloudhealth-operation-summary
Every operation must include a short summary.
$.paths[*][get,post,put,patch,delete]
warn
cloudhealth-error-responses
Mutating operations should declare 4xx error responses.
$.paths[*][post,put,patch,delete].responses

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

# Spectral linting rules for any OpenAPI describing the CloudHealth REST
# API at chapi.cloudhealthtech.com.
rules:
  cloudhealth-info-contact:
    description: API contact information must be present.
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

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

  cloudhealth-server-https:
    description: All server URLs must use HTTPS for the chapi.cloudhealthtech.com control plane.
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  cloudhealth-server-host:
    description: Server URLs should target chapi.cloudhealthtech.com.
    severity: warn
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "chapi\\.cloudhealthtech\\.com"

  cloudhealth-versioned-paths:
    description: CloudHealth REST API paths should be versioned (/v{N}/) where applicable.
    severity: warn
    given: "$.paths"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          patternProperties:
            "^/(v\\d+/.*|olap_reports/.*)": {}
          additionalProperties: true

  cloudhealth-auth-required:
    description: A bearer security scheme must be declared.
    severity: error
    given: "$.components.securitySchemes"
    then:
      function: truthy

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

  cloudhealth-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

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

  cloudhealth-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"]