-
Notifications
You must be signed in to change notification settings - Fork 35
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
nullable is not recognized / respected in schema #51
Comments
Some more research suggested to change the syntax as following:
That did not change anything. |
I think this is a side effect of the differences in Open API spec and JSON schema. The validator library that exegesis uses is AJV. I came across this bug ajv-validator/ajv#486 which suggests adding a custom keyword. |
Ah, I'm afraid I misread the spec:
I assumed "for further schema documentation" meant these fields were mostly informational (and, indeed, most of these we don't care about from a schema validation viewpoint, except maybe I assumed you could do something like:
Except, for some weird reason, null is not supported as a type. So yeah, we're going to need to add a custom keyword. |
Glad to see this is indeed a bug, so it can be fixed. :-) Thank you both for the quick responses. I meanwhile confirmed that the code example @jwalton gave in his comment indeed does not work (schema is then invalid and app will not start). |
Oh and @jwalton, if I can do anything to help fix this issue let me know! |
@jwalton It hasn't been released yet but there is a fix for this on the master branch ajv-validator/ajv@f2010f4 so worth keeping an eye on. @cgredig Writing a failing test, that is small and concise, is always a good way to contribute. For example, writing a patch like the following which can be used to confirm the issue and also to validate the fix.
|
@cgredig If you want to take a stab at writing a custom keyword for AJV, I wouldn't say no. :) I was hoping I could get to it but I'm buried in a rewrite of our front end right now. :( |
As a result of the divergence of the OpenAPI spec and JSON Schema the underlying Ajv libary needed upgraded to support for the nullable field. Issues: Fixes exegesis-js#51
🎉 This issue has been resolved in version 1.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Awesome! Thanks a lot for fixing this, I upgraded exegesis in my app and can confirm the fix resolves my issues. :) |
Hey there,
I was trying to convert a former Swagger 2 application to OpenAPI 3, switching to Exegesis. I began by following the Exegesis Tutorial which worked. Then I replaced the OpenAPI yaml and adjusted some names. Now my requests are still accepted and reply as expected - except if one of the fields is null. This was the original reason why I wanted to switch to OpenAPI 3 - it has the "nullable" attribute. Sadly, this seems to be ignored by exegesis.
So, here is my OpenAPI doc (it describes something similar to the payload sent by Bitbucket with webhooks):
The request I send is a POST request to the URL http://localhost:3000/push?GIT_BRANCH=develop with the body as follows:
As you can see, the value for push.changes[0].old is null, which is why I made the according schema nullable. Still, I receive the following answer:
How is that possible? Apart from some names, I did not change the options or the content of index.js as explained in the tutorial.
(Field contents in the payload have been partly anonymized.)
The text was updated successfully, but these errors were encountered: