-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Keyword discriminator from Open API 3 Specification #35
Comments
Is this feature still planned? |
No. This keyword is for tools only in v3, it doesn't do any validation any more. |
Sorry to bother you again. |
I may be wrong, but I think in OpenAPI v3 you must use oneOf, discriminator is just to inform the tools what is the logic behind these oneOfs. My understanding is that removing discriminator in v3 should always result in the same validation outcome (valid/invalid), but may affect error reporting or some other behaviours. So from validation point of view it can be just ignored. |
👍 thank you! I've studied a little and in the end, I've used the |
@epoberezkin for the most part, this statement is accurate, however, i believe when defaults are involved the discriminator is necessary to clear up ambiguities. That is, its role ends up being more than just informing tools. For example, given this openapi 3 spec where Is there a way this can be solved? |
@cdimascio raised this issue in response to one I raised with him against the otherwise excellent express-openapi-validator I'm using in a high profile project. The schema is enormous and was intented to include many thousands of constant values. However, as discussed for over two years now, OpenAPI 3.x does not support a constant datatype, though JSON Schema does. Our client demands the API be specified in OpenAPI 3 so I was using the "enum with one value and default" work-around in lieu of a constant type, but this broke @cdimascio's validator, and every other one I tried, when combined with discriminators for oneOf. I do not have the luxury of waiting for a fix, but would like to know the OpenAPI community is considering this as an enhancement to the specification so my manual, ugly hack to provide consumers with easy access to thousands of identically named but differently scoped constant values can eventually be consigned to the bin. |
created see ajv-validator/ajv#1119 for discriminator keyword discrimitator cannot be implemented as a separate keyword, only as an extension of oneOf functionality - from validation point of view it's no-op. Defaults are just meta-data from JSON Schema spec point of view, the spec does notdefine how it should be processed. |
No description provided.
The text was updated successfully, but these errors were encountered: