OpenAPI discriminator keyword #236
Replies: 2 comments 17 replies
-
|
It seems you have confused. there is no relation between have you seen https://github.com/santhosh-tekuri/jsonschema/blob/boon/example_vocab_discriminator_test.go this is an implementation of |
Beta Was this translation helpful? Give feedback.
-
|
it seems this discussion is not reaching any conclusion. Just give me minimal openapi sample file, and input json, I will show how to do the validation. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I was looking into an issue I had with
libopenapi-validator(which usesjsonschemafor validation) and came to the conclusion that thediscriminatorfeature of OpenAPI cannot be easily supported currently becausejsonschemadoes not provide a way to extend the validation logic. In this case it is the logic for conditional keywords likeoneOf. Obviously, this has not much to do with this library since we are talking about OpenAPI but maybe someone has an idea on how this could be implemented / improved.The problem is the following: OpenAPI has a conditional keyword named
oneOf. What that does is it makes object schemas conditional and enables having multiple schemas for one object. This is useful for when for example you have a login endpoint and want to support multiple ways to log into the application. To help with this, thediscriminatorkeyword can be defined to improve the schema matching.My question here is, how could this be implemented with this library? Would it make sense to add a way to extend validation logic directly in
jsonschema? I would contribute and help implementing this feature if it makes sense.Beta Was this translation helpful? Give feedback.
All reactions