open-api icon indicating copy to clipboard operation
open-api copied to clipboard

openapi-request-validator throws error without errorCode

Open kruai opened this issue 6 years ago • 3 comments

When sending xml instead of json in the body of a POST, I'd expect a media-type error to be returned from the request validator. For some reason, though, it throws an error with an undefined errorCode.

More specifically, this is happening when I make a POST with the header Content-Type: application/xml and the body <test>hello</test>

I'm wondering if this is because of mediaTypeError being treated differently here: https://github.com/kogosoftwarellc/open-api/blob/master/packages/openapi-request-validator/index.ts#L305

kruai avatar Apr 15 '19 15:04 kruai

i'm not sure we have xml being serialized to json yet. you'd have to add support for this.

jsdevel avatar Apr 15 '19 22:04 jsdevel

@jsdevel I think the point here is the inconsistency in error reporting. All errors raised by openapi-request-validator do specify errorCode except for mediaTypeError and schemaError which don't.

jharting avatar Apr 16 '19 09:04 jharting

please open a PR

jsdevel avatar Apr 16 '19 16:04 jsdevel