Anchore · API Governance Rules

Anchore API Rules

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

19 Rules error 5 warn 12 info 1
View Rules File View on GitHub

Rule Categories

anchore error no operationid path query schema security servers

Rules

error
anchore-openapi-info-description
OpenAPI info object must have a description
$.info
error
anchore-openapi-info-version
OpenAPI info object must have a version
$.info
error
anchore-operation-operationId
Every operation must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
anchore-operation-summary
Every operation must have a summary
$.paths[*][get,post,put,patch,delete]
warn
anchore-response-200
Every GET operation must have a 200 response
$.paths[*].get.responses
error
anchore-security-defined
API must define security requirements
$
warn
anchore-schema-type
Schema properties must have a type
$.components.schemas[*].properties[*]
warn
anchore-severity-enum
Vulnerability severity must use standard values
$.components.schemas.Vulnerability.properties.severity
hint
anchore-digest-format
Image digest fields should follow SHA256 format
$.components.schemas[*].properties.imageDigest
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-expected-domain
Server URLs should be on the example.com domain.
$.servers[*].url
warn
path-params-casing
Path parameters should be camelCase (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
warn
query-params-casing
Query parameters should be snake_case (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
operationid-casing
Operation IDs should be camelCase (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].operationId
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
info
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
security-schemes-defined
Security schemes should be defined in components.
$.components
warn
error-schema-defined
A shared error schema (ErrorResponse) should be defined for error payloads.
$.components.schemas
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# anchore — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 1/1 servers on example.com
#   - path-params-casing: camel @ 80% (n=5)
#   - query-params-casing: snake @ 80% (n=5)
#   - operationid-casing: camel @ 100% (n=11)
#   - schema-names-casing: pascal @ 93% (n=14)
#   - schema-properties-casing: snake @ 52% (n=68)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: ErrorResponse
#   - merge: kept 9 existing, added 10 measured, upgraded 0
#   - added: servers-https-only, servers-expected-domain, path-params-casing, query-params-casing, operationid-casing, schema-names-casing, schema-properties-casing, security-schemes-defined, error-schema-defined, no-empty-descriptions
extends:
  - spectral:oas
rules:
  anchore-openapi-info-description:
    description: OpenAPI info object must have a description
    message: Info object must have a description
    given: $.info
    severity: error
    then:
      field: description
      function: truthy
  anchore-openapi-info-version:
    description: OpenAPI info object must have a version
    message: Info object must have a version
    given: $.info
    severity: error
    then:
      field: version
      function: truthy
  anchore-operation-operationId:
    description: Every operation must have an operationId
    message: Operation must have an operationId
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: operationId
      function: truthy
  anchore-operation-summary:
    description: Every operation must have a summary
    message: Operation must have a summary
    given: $.paths[*][get,post,put,patch,delete]
    severity: warn
    then:
      field: summary
      function: truthy
  anchore-response-200:
    description: Every GET operation must have a 200 response
    message: GET operations must define a 200 response
    given: $.paths[*].get.responses
    severity: warn
    then:
      field: '200'
      function: truthy
  anchore-security-defined:
    description: API must define security requirements
    message: API must define global security
    given: $
    severity: error
    then:
      field: security
      function: truthy
  anchore-schema-type:
    description: Schema properties must have a type
    message: Schema property must have a type
    given: $.components.schemas[*].properties[*]
    severity: warn
    then:
      field: type
      function: truthy
  anchore-severity-enum:
    description: Vulnerability severity must use standard values
    message: Severity must be one of Critical, High, Medium, Low, Negligible, Unknown
    given: $.components.schemas.Vulnerability.properties.severity
    severity: warn
    then:
      function: truthy
  anchore-digest-format:
    description: Image digest fields should follow SHA256 format
    message: imageDigest should be a string type
    given: $.components.schemas[*].properties.imageDigest
    severity: hint
    then:
      field: type
      function: truthy
  servers-https-only:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-expected-domain:
    description: Server URLs should be on the example.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: example\.com
  path-params-casing:
    description: Path parameters should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*].parameters[?(@.in=='path')].name
    then:
      function: casing
      functionOptions:
        type: camel
  query-params-casing:
    description: Query parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: snake
  operationid-casing:
    description: Operation IDs should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: casing
      functionOptions:
        type: camel
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*$
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  security-schemes-defined:
    description: Security schemes should be defined in components.
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  error-schema-defined:
    description: A shared error schema (ErrorResponse) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: ErrorResponse
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy