resonses:
...
application/json:
schema:
$ref: '#/components/schemas/Example'
examples:
default:
$ref: '#/components/examples/ExampleResponse'
...
components:
...
examples:
ExampleResponse:
summary: example response summary
value:
name: null # this null value causes the exception
This is the resulting stack trace:
TypeError: Cannot read properties of null (reading 'type')
at Object.$.paths..[?(@.type === 'string' && (@.format === 'date-time' || @.format === 'date' || @.format === 'time' || @.format === 'duration' || @.format === 'period'))] (eval at query (node_modules/nimma/dist/legacy/cjs/core/index.js:66:71), <anonymous>:117:31)
at eval (eval at query (node_modules/nimma/dist/legacy/cjs/core/index.js:66:71), <anonymous>:201:176)
at _traverseBody (node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:13:5)
at _traverse (node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:41:7)
at _traverseBody (node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:17:5)
Side note: I'm not sure if the operator === is "standard" for JSONPath filters but it seems not to cause the issue. Never the less == seem to be more common.
Somehow it seems that the newly introduced Zalando rule 169 causes an issue in cases with
null
properties.I stumbled over the issue in a case where a response example references an Example that contains a null property.
To better illustrate the issue, I created a draft PR that showcases it: https://github.com/baloise-incubator/spectral-ruleset/pull/60
This is the resulting stack trace:
Side note: I'm not sure if the operator
===
is "standard" for JSONPath filters but it seems not to cause the issue. Never the less==
seem to be more common.