Skip to content

Spectral Linting Rules

The project uses Spectral for OAS3 linting with a two-config architecture that separates CI/external tooling from the pipeline’s custom logic.

Used by GitHub Super-Linter and any external CI tool. Extends spectral:oas (the built-in OAS ruleset). Contains no custom functions — this keeps it compatible with tools that run Spectral without access to the spectral/functions/ directory.

extends:
- "spectral:oas"
rules:
path-params: "off"
operation-tags: warn
oas3-api-servers: warn
info-contact: warn
oas3-unused-component: warn
operation-operationId-unique: error
oas3-valid-schema-example: error
no-script-tags-in-markdown: warn
operation-description: info
info-description: info

spectral-pipeline.yaml — Pipeline Config

Section titled “spectral-pipeline.yaml — Pipeline Config”

Used by scripts/spectral_lint.py (both discover and gate modes). Extends the base config and adds the custom f5-path-params function:

extends:
- "./.spectral.yaml"
functionsDir: "./spectral/functions"
functions:
- f5-path-params
rules:
f5-path-params:
description: "Path parameters must be declared and used"
message: "{{error}}"
severity: error
given: "$.paths[*]"
then:
function: f5-path-params

Spectral’s built-in path-params rule incorrectly flags F5 XC APIs that use dotted parameter names like {metadata.namespace} and {metadata.name}. The built-in rule does not parse dots in parameter names, so it reports them as undeclared.

The custom f5-path-params function (spectral/functions/f5-path-params.js) correctly handles dotted names by matching the full {placeholder} content against declared parameter names. It checks both path-level and operation-level parameters, and reports errors in both directions:

  • A placeholder in the URL path that has no matching parameter declaration
  • A declared path parameter that does not appear in the URL path

These rules are auto-fixed by the reconciler when violations are detected. See Fixes Applied for details on each fix.

RuleSeverityFix MethodDescription
oas3-api-serverswarn_add_serversSpec must have a servers block
info-contactwarn_add_contactinfo must include contact
operation-tagswarn_add_tagsEvery operation must have at least one tag
oas3-unused-componentwarn_remove_unused_componentNo unreferenced component schemas
operation-operationId-uniqueerror_deduplicate_operation_idAll operationIds must be unique
oas3-valid-schema-exampleerror_fix_schema_exampleExamples/defaults must match their schema
no-script-tags-in-markdownwarn_strip_script_tagsNo <script> tags in descriptions
f5-path-paramserrorPath parameters must be declared and used

These rules are downgraded to info severity because they cannot be auto-fixed meaningfully:

RuleSeverityDescription
operation-descriptioninfoOperations should have a description
info-descriptioninfoAPI info should have a description

The Spectral adapter (scripts/spectral_lint.py) runs in two modes:

Terminal window
make spectral-lint
# Equivalent to: python -m scripts.spectral_lint --mode discover

Scans specs/original/ and writes reports/spectral_report.json. The reconciler consumes this report alongside the validation report.

Terminal window
make spectral-gate
# Equivalent to: python -m scripts.spectral_lint --mode gate

Scans release/specs/ and writes reports/spectral_gate_report.json. Returns exit code 1 if violations exceed the configured thresholds.

Spectral violations are converted to Discrepancy objects with three subtypes:

Spectral Rule CategoryDiscrepancyTypeExample Rules
Missing required elementSPECTRAL_MISSINGoas3-api-servers, info-contact, operation-tags
Invalid existing elementSPECTRAL_INVALIDoas3-valid-schema-example, no-script-tags-in-markdown
Dead codeSPECTRAL_UNUSEDoas3-unused-component