-
-
Notifications
You must be signed in to change notification settings - Fork 882
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
OneOf property is failing during OAS Schema Validation #2349
Comments
According to the docs, mapping is not supported: https://ajv.js.org/json-schema.html#discriminator. It's unclear clear why that's the case. If the author is open to a PR perhaps you could add the feature? |
It looks like somebody has already attempted that: https://github.com/ajv-validator/ajv/pull/2262/files |
@mefellows then only with oneOf with discriminator is possible? |
I don't think mapping is supported at all. |
@mefellows alternated is then using extract policy validation? |
I'm not sure what that means, sorry, but to work around it you can not using the mapping. See https://swagger.io/specification/v3/#discriminator-object for how it works without mapping. |
OpenAPI defines discriminator as tooling support and no-op from validation point of view - actual validation happens as defined in oneOf. Mapping may lead to contradictory schema, so is not supported. You can add it as a custom keyword to be ignored and allowed in schemas. Also, you have to use discriminator option. |
Thanks for your response @epoberezkin! I'm still a little confused as to why we wouldn't want to support this feature. I appreciate it's not currently supported and it's a limitation (as you had documented already).
That's not how I read the spec: https://spec.openapis.org/oas/v3.0.3#discriminator-object. I'm not all that familiar with spec reading and interpretation, so perhaps I'm mistaken. Or should I be looking at the JSON Schema dialect for this?
Is this something
This will have the effect of ignoring the mapping, correct? I'm looking for a solution that would include incorporating the entire mapping and discriminator vocabulary into the parsing of the document. If you know of a workaround, I would be very grateful to hear of it. |
Hello Team,
Requesting you to please check this issue and help. Performing schema validation with oneOf, discriminator and mapping property in oas3.0.
Error:
{
"fault": {
"faultstring": "OASValidation MAM-EXT-SpecValidation with resource "oas://openapi.yaml": failed with reason: "[ERROR - An error occurred during schema validation - com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException.: []]"",
"detail": {
"errorcode": "steps.oasvalidation.Failed"
}
}
}
yaml file looks like:
json payload looks like:
--data '{ "billableHeader": { "sourceSystem": "UPSTREAM_APP", "sourceTransactionType": "INVOICE", "eventType": "BATCH", "messageCreationDatetime": "20220811140203", "timeZoneCode": "GMT", "isBulkProcessing": true, "product": "Airlcl" },
The text was updated successfully, but these errors were encountered: