Closed pedrodovale closed 2 years ago
come chat about it here https://apisyouwonthate.com/community
I've confirmed this is not working, despite the JSON Path being valid. I'll get some of the crew at Stoplight to help figure it out.
The rule thats trouble is:
no-unknown-error-format:
description: "Every error response SHOULD support either RFC 7807 (https://tools.ietf.org/html/rfc6648) or the JSON:API Error format."
formats: [oas3]
severity: warn
given: $.paths.[*].responses[?(@property.match(/^(4|5)/))].content.*~
then:
function: enumeration
functionOptions:
values:
- application/vnd.api+json
- application/problem+xml
- application/problem+json
Fixed in 06bd2f7 thanks to help from @savage-alex
I'm trying to make a custom rule based on the unkown-error-format that can be found here here. Using this Open API document as an example:
openapi-generated.yaml
and this rule set:
.spectral.yml
When running
spectral lint --ruleset .spectral.yml openapi-generated.yaml
I was expecting an error to be returned, because the 500 response content is
application/json
and not one ofapplication/vnd.api+json
,application/problem+xml
,application/problem+json
.Instead no errors are found.
Additionally, I tried using this JSON Path Demo to check if the output array with "application/json" is returned for the path in the rule's given. It does.
Is there a problem with this rule or am I doing something wrong?
Thanks in advance.