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
v4 UnhandledPromiseRejectionWarning: Error: openapi.validator: args.apiDoc was invalid. #551
Comments
@waynebloss fixed in it should now work as expected in the default case i.e. whre in the case, where one opts to set |
@cdimascio Thank you. This fixes the unhandled promise rejection, but with this change I'm wondering how I can programatically detect the error that happens when Specifically, I'd like to find out about this error once at startup so I can print an extended help message for other devs. |
@cdimascio If you're not interested in doing anything for this and you'd rather see a pull request I can do that. I'm wondering what would be acceptable. A new option to add to If you don't want to add anything, that's fine too - I can certainly continue to just re-implement |
Actually, for my own personal project which is the only project using v4 of this Thanks for your excellent work! |
Describe the bug
Cannot handle the promise created in openApiValidator in src/index.ts.
To Reproduce
Install the middleware with a bad
apiSpec
. Since I was specifically testing how to catch this error in v4, I created a badapiSpec
with an incorrectly formedoperations.parameters
field (e.g.parameters: { q: "string" },
).If you pass
validateApiSpec: true
you get the error in the title. Otherwise, you getTypeError: undefined is not a function
. In both cases, there is no output saying what is invalid in theapiSpec
.Actual behavior
An uncatchable
UnhandledPromiseRejectionWarning
occurs and depending on the value ofvalidateApiSpec
, could be quite difficult for some people to debug.Expected behavior
Be able to handle the promise like in v3 when you called
OpenApiValidator.install(app).then().catch()...
.Examples and context
Full reproduction.
Workaround
Basically, reproduce the code in src/index.ts.
With
writeDeveloperErrorHelp
in place I get a nice error printout and the server continues to startup and run:Full error report when validateApiSpec is true
Full error report when validateApiSpec is false
The text was updated successfully, but these errors were encountered: