Problem description
Findings for rules like S-211 (unused component) and S-313 (string missing
format/pattern/enum) render only path:line in the Step Summary, and the underlying Spectral
message text for both rules is a static string with no location detail:
- S-211:
"Potentially unused component has been detected."
- S-313:
"Schema of type string should specify a format, pattern, enum, or const."
Reviewers have to open the spec at that line to find out which schema/component a finding is
about, which is painful on larger specs.
Possible evolution
spectral_adapter.py already captures a schema_path (dot-joined JSONPath) for every Spectral
finding; format_finding_location() in validation/output/formatting.py just doesn't read it.
Extend it: when schema_path matches components.(schemas|parameters|responses|requestBodies|headers).<name>,
append (<name>) to the rendered location, e.g.
code/API_definitions/quality-on-demand.yaml:342 (QosProfile). This applies uniformly to any
Spectral-engine finding whose schema_path resolves to a named component, not only S-211/S-313.
When schema_path doesn't resolve to a named component (e.g. an inline string schema under
paths.*, which S-313's document-wide scan can also hit), leave the location unchanged.
Alternative solution
Show the full schema_path instead of just the trailing component name — considered and
rejected: it gets long for deeply nested properties, and the component name alone is what's
needed to find the schema in the spec.
Additional context
Regression fixtures (regression-expected-schema.yaml) match findings on (rule_id, path, level) only — line numbers and messages are explicitly excluded from the match key — so this is
a rendering-only change with no regression-fixture impact.
Problem description
Findings for rules like S-211 (unused component) and S-313 (string missing
format/pattern/enum) render only
path:linein the Step Summary, and the underlying Spectralmessage text for both rules is a static string with no location detail:
"Potentially unused component has been detected.""Schema of type string should specify a format, pattern, enum, or const."Reviewers have to open the spec at that line to find out which schema/component a finding is
about, which is painful on larger specs.
Possible evolution
spectral_adapter.pyalready captures aschema_path(dot-joined JSONPath) for every Spectralfinding;
format_finding_location()invalidation/output/formatting.pyjust doesn't read it.Extend it: when
schema_pathmatchescomponents.(schemas|parameters|responses|requestBodies|headers).<name>,append
(<name>)to the rendered location, e.g.code/API_definitions/quality-on-demand.yaml:342 (QosProfile). This applies uniformly to anySpectral-engine finding whose
schema_pathresolves to a named component, not only S-211/S-313.When
schema_pathdoesn't resolve to a named component (e.g. an inline string schema underpaths.*, which S-313's document-wide scan can also hit), leave the location unchanged.Alternative solution
Show the full
schema_pathinstead of just the trailing component name — considered andrejected: it gets long for deeply nested properties, and the component name alone is what's
needed to find the schema in the spec.
Additional context
Regression fixtures (
regression-expected-schema.yaml) match findings on(rule_id, path, level)only — line numbers and messages are explicitly excluded from the match key — so this isa rendering-only change with no regression-fixture impact.