CRI-O · API Governance Rules

CRI-O API Rules

Spectral linting rules defining API design standards and conventions for CRI-O.

7 Rules error 6 warn 1
View Rules File View on GitHub

Rule Categories

cri

Rules

error
cri-o-metrics-info-license
API info object should declare the Apache 2.0 license.
$.info.license
warn
cri-o-metrics-server-port
Server URL should reference the default metrics port 9090.
$.servers[*].url
error
cri-o-metrics-paths
API must define the /metrics path.
$.paths
error
cri-o-metrics-get-only
Metrics endpoint must only support GET.
$.paths['/metrics']
error
cri-o-metrics-text-plain-response
Metrics 200 response must be text/plain (Prometheus exposition format).
$.paths['/metrics'].get.responses.200.content
error
cri-o-metrics-operation-id
Operations must define an operationId.
$.paths.*.get
error
cri-o-metrics-tags
Operations must define tags.
$.paths.*.get

Spectral Ruleset

Raw ↑
extends: ["spectral:oas"]
documentationUrl: https://github.com/cri-o/cri-o/blob/main/docs/metrics.md
rules:
  cri-o-metrics-info-license:
    description: API info object should declare the Apache 2.0 license.
    given: "$.info.license"
    severity: error
    then:
      field: name
      function: pattern
      functionOptions:
        match: "Apache"
  cri-o-metrics-server-port:
    description: Server URL should reference the default metrics port 9090.
    given: "$.servers[*].url"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "9090"
  cri-o-metrics-paths:
    description: API must define the /metrics path.
    given: "$.paths"
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - /metrics
  cri-o-metrics-get-only:
    description: Metrics endpoint must only support GET.
    given: "$.paths['/metrics']"
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            get:
              type: object
          additionalProperties: false
  cri-o-metrics-text-plain-response:
    description: Metrics 200 response must be text/plain (Prometheus exposition format).
    given: "$.paths['/metrics'].get.responses.200.content"
    severity: error
    then:
      field: text/plain
      function: truthy
  cri-o-metrics-operation-id:
    description: Operations must define an operationId.
    given: "$.paths.*.get"
    severity: error
    then:
      field: operationId
      function: truthy
  cri-o-metrics-tags:
    description: Operations must define tags.
    given: "$.paths.*.get"
    severity: error
    then:
      field: tags
      function: truthy