Cloud Native Buildpacks · API Governance Rules

Cloud Native Buildpacks API Rules

Spectral linting rules defining API design standards and conventions for Cloud Native Buildpacks.

8 Rules error 3 warn 4 info 1
View Rules File View on GitHub

Rule Categories

cnb

Rules

error
cnb-info-contact
API contact information must be present.
$.info
warn
cnb-info-license
API license must be declared (CNB is Apache-2.0).
$.info
error
cnb-server-https
All server URLs must use HTTPS.
$.servers[*].url
warn
cnb-operation-tags
Every operation must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
cnb-operation-summary
Every operation must include a short summary.
$.paths[*][get,post,put,patch,delete]
error
cnb-operation-id
Every operation must declare a unique operationId.
$.paths[*][get,post,put,patch,delete]
warn
cnb-error-responses
Mutating operations should declare 4xx error responses.
$.paths[*][post,put,patch,delete].responses
info
cnb-buildpack-id-pattern
Buildpack IDs should follow the reverse-DNS convention.
$.paths[?(@property.match(/buildpack/))]

Spectral Ruleset

cloud-native-buildpacks-rules.yml Raw ↑
extends:
  - spectral:oas

# Spectral linting rules for Cloud Native Buildpacks specs.
# CNB does not expose a runtime HTTP API directly; these rules
# apply to ancillary services such as the Buildpack Registry API
# and any platform integrations that wrap the lifecycle.
rules:
  cnb-info-contact:
    description: API contact information must be present.
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

  cnb-info-license:
    description: API license must be declared (CNB is Apache-2.0).
    severity: warn
    given: "$.info"
    then:
      field: license
      function: truthy

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

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

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

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

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

  cnb-buildpack-id-pattern:
    description: Buildpack IDs should follow the reverse-DNS convention.
    severity: info
    given: "$.paths[?(@property.match(/buildpack/))]"
    then:
      function: truthy