CoreDNS · API Governance Rules

CoreDNS API Rules

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

8 Rules error 5 warn 2 info 1
View Rules File View on GitHub

Rule Categories

coredns

Rules

error
coredns-metrics-info-license
API info object should declare Apache 2.0.
$.info.license
warn
coredns-metrics-port-9153
Servers should reference port 9153 (default Prometheus metrics port).
$.servers[*].url
error
coredns-metrics-path
API must define the /metrics path.
$.paths
error
coredns-metrics-get-only
The /metrics endpoint must only support GET.
$.paths['/metrics']
warn
coredns-metrics-prometheus-response
200 response should return text/plain Prometheus exposition format.
$.paths['/metrics'].get.responses.200.content
error
coredns-metrics-operation-id
Operations must define an operationId.
$.paths.*.get
error
coredns-metrics-tags
Operations must define tags.
$.paths.*.get
info
coredns-metrics-no-auth
Metrics endpoint typically does not require authentication; consider documenting this.
$.paths['/metrics'].get

Spectral Ruleset

Raw ↑
extends: ["spectral:oas"]
documentationUrl: https://coredns.io/plugins/metrics/
rules:
  coredns-metrics-info-license:
    description: API info object should declare Apache 2.0.
    given: "$.info.license"
    severity: error
    then:
      field: name
      function: pattern
      functionOptions:
        match: "Apache"
  coredns-metrics-port-9153:
    description: Servers should reference port 9153 (default Prometheus metrics port).
    given: "$.servers[*].url"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: ":9153"
  coredns-metrics-path:
    description: API must define the /metrics path.
    given: "$.paths"
    severity: error
    then:
      field: /metrics
      function: truthy
  coredns-metrics-get-only:
    description: The /metrics endpoint must only support GET.
    given: "$.paths['/metrics']"
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            get:
              type: object
          additionalProperties: false
  coredns-metrics-prometheus-response:
    description: 200 response should return text/plain Prometheus exposition format.
    given: "$.paths['/metrics'].get.responses.200.content"
    severity: warn
    then:
      field: text/plain
      function: truthy
  coredns-metrics-operation-id:
    description: Operations must define an operationId.
    given: "$.paths.*.get"
    severity: error
    then:
      field: operationId
      function: truthy
  coredns-metrics-tags:
    description: Operations must define tags.
    given: "$.paths.*.get"
    severity: error
    then:
      field: tags
      function: truthy
  coredns-metrics-no-auth:
    description: Metrics endpoint typically does not require authentication; consider documenting this.
    given: "$.paths['/metrics'].get"
    severity: info
    then:
      function: truthy