Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validateResponse does not account for specification extensions that are null #73

Closed
todanator opened this issue Oct 14, 2017 · 1 comment

Comments

@todanator
Copy link
Contributor

todanator commented Oct 14, 2017

#74

A responses object with a Specification Extension with the type null will throw and error

Cannot read property 'headers' of null

You can see here that responses should be extendable
https://swagger.io/specification/#responsesObject

h2. Test
Example responses object

"responses": {
	"x-an-extension-null": null,
	"200": {}
}

'response' will evaluate to null here:
/~https://github.com/BigstickCarpet/swagger-parser/blob/master/lib/validate-spec.js#L49
And throw the error here for trying to access null.headers
/~https://github.com/BigstickCarpet/swagger-parser/blob/master/lib/validate-spec.js#L251

Suggest either filtering extensions or null safe access of headers.

@JamesMessinger
Copy link
Member

Thanks for reporting this issue and submitting a PR. I've merged your changes, and they should be published to npm within the next few days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants