File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -273,7 +273,10 @@ def format_finding_location(finding: dict) -> str:
273273
274274 When ``schema_path`` identifies a named OpenAPI component (Spectral-engine
275275 findings only), the component name is appended in parens, e.g.
276- ``spec.yaml:42 (QosProfile)``.
276+ ``spec.yaml:42 (QosProfile)``. When ``schema_path`` is present but does not
277+ resolve to a named component (e.g. an inline parameter or body schema),
278+ ``(inline definition)`` is appended instead, so the reader still knows the
279+ hit isn't a defined component to look up elsewhere in the spec.
277280 """
278281 path = finding .get ("path" , "" )
279282 line = finding .get ("line" , 0 )
@@ -282,9 +285,12 @@ def format_finding_location(finding: dict) -> str:
282285 location = f"{ path } :{ line } :{ column } "
283286 else :
284287 location = f"{ path } :{ line } "
285- match = _COMPONENT_PATH_RE .match (finding .get ("schema_path" ) or "" )
288+ schema_path = finding .get ("schema_path" ) or ""
289+ match = _COMPONENT_PATH_RE .match (schema_path )
286290 if match :
287291 return f"{ location } ({ match .group (1 )} )"
292+ if schema_path :
293+ return f"{ location } (inline definition)"
288294 return location
289295
290296
Original file line number Diff line number Diff line change @@ -316,9 +316,14 @@ def test_component_schema_path_appends_name(self):
316316 f ["schema_path" ] = "components.schemas.QosProfile"
317317 assert format_finding_location (f ) == "spec.yaml:42 (QosProfile)"
318318
319- def test_non_component_schema_path_unchanged (self ):
319+ def test_non_component_schema_path_gets_inline_label (self ):
320320 f = _make_finding (path = "spec.yaml" , line = 42 )
321321 f ["schema_path" ] = "paths./foo.get.parameters.0.schema"
322+ assert format_finding_location (f ) == "spec.yaml:42 (inline definition)"
323+
324+ def test_absent_schema_path_unchanged (self ):
325+ f = _make_finding (path = "spec.yaml" , line = 42 )
326+ assert "schema_path" not in f
322327 assert format_finding_location (f ) == "spec.yaml:42"
323328
324329
You can’t perform that action at this time.
0 commit comments