-
-
Notifications
You must be signed in to change notification settings - Fork 264
Open
Description
Description
The oas3-examples-value-or-externalValue
rule incorrectly reports errors against valid examples in components/examples
when there are broken $ref
references to non-existent examples elsewhere in the OpenAPI file.
Expected Behavior
- Valid examples with proper
value
orexternalValue
fields should pass validation - The
oas3-examples-value-or-externalValue
rule should not trigger false positives
Actual Behavior
- Valid examples in
components/examples
that have propervalue
fields are incorrectly flagged - Error is reported at
path: ["components", "examples"]
instead of the broken reference location
Minimal Reproduction
File: minimal-reproduction.yaml
openapi: 3.0.3
info:
title: Minimal Test
version: 1.0.0
paths:
/test:
get:
responses:
'200':
content:
application/json:
examples:
test:
$ref: '#/components/examples/non-existent' # ← BROKEN REFERENCE
components:
examples:
valid-example: # ← CORRECTLY FORMATTED
value:
test: "data"
Command to reproduce:
spectral lint minimal-reproduction.yaml
Expected output: Error about broken $ref
reference
Actual output:
{
"code": "oas3-examples-value-or-externalValue",
"path": ["components", "examples"],
"message": "Examples must have either \"value\" or \"externalValue\" field.",
"range": {
"start": {"line": 15, "character": 11},
"end": {"line": 18, "character": 20}
}
}
Metadata
Metadata
Assignees
Labels
No labels