-
Notifications
You must be signed in to change notification settings - Fork 536
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
Incorrect BodyProcessorException: [Bad Request] Validation error for body application/json: More than one schema valid #1820
Comments
tl;dr discriminator is ignored from the vertx-json-schema validator, on each field type definition use
The long story here is that the discriminator is still not supported, there is a WIP PR here, where I still have some concerns about it, but in general the discriminator is a weird feature of openapi 3, because it goes a bit against the design philosophy of json schema (and making it weird to implement). If that's something people is interested in, I'll try to get back to that PR and fix it, in order to support discriminator properly. In any case, I think your schemes miss the |
I use the workaround you provided (more exactly, I have added the property I think that discriminator is very usefull, there is this use-case of course (type discrimination), but also, in another project, the business model was event sourced with almost 200 type of event and in this case discrimator is a shortcut to determine quickly which of Not supporting it and relying on property declaration can lead to weird issue (on weird serialization case, I admit). In this sample a collection of Also use the add-property-with-enum way make harder to use some code generator based on openapi schema which treat this property as 'real' property rather 'for-serialization-only` property. But as I said in initial post, the OpenAPI spec say |
Well you can have both discriminator and the add-property-with-enum way, they certainly don't exclude each other. I see how the discriminator works very well for serde tools, but they make more complex the validation, because in json schema validation keywords are meant to be independent but discriminator creates a "bond" between different keywords, hence my issue with supporting it properly.
I see that this is in OpenAPI 3.1 too, so I eventually won't have any choice than supporting it 😄. I'll see what I can do, starting from eclipse-vertx/vertx-json-schema#18 |
Great News ! (easy to say when you're not the maintainer). |
I've opened an issue in json schema to discuss about that: eclipse-vertx/vertx-json-schema#31 |
I close this and mark it as wontfix, as discussed in eclipse-vertx/vertx-json-schema#31 |
Version
4.0.0
Context
Given an openapi schema like :
And a body :
I expect vertx to be able to match the correct type but I got :
Do you have a reproducer?
No
Others
The specification (https://swagger.io/specification/#discriminator-object) say that the implementor
MAY
use discriminator, so it's questionnable, but I think that when the discriminator is here, vertx should use it to see that only one type match (and to speedup matching)The text was updated successfully, but these errors were encountered: