-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Validating an enum array does not seem to work #203
Comments
Indeed this It's probably time to replace it with https://github.com/xeipuuv/gojsonschema If you want to take this on I'll gladly help! |
Would not mind contributing - but this may be too big a fish to swallow! Let me investigate |
I've cleaned up error message, and it seems like you have enum on the array level, not item.
|
Indeed the cited YAML and the error message don't match. Thanks @iron-s ! Looks like schema should instead be either of: type: array
items:
type: string
enum:
- Admin
- Prescriber
- Clinician or type: array
items:
type: string
enum:
- [Admin]
- [Prescriber]
- [Clinician] Note, that last schema will cause a panic due to #646 The issue you're having is because you schema is type: array
items:
type: string
enum:
- Admin
- Prescriber
- Clinician (note how the enum values do not match the surrounding schema) |
Closing this as this was identified as not being this lib's issue. |
I have the following schema:
When I try to validate the array field with input
["Admin"]
- I get the following error:code=400, message=Request body has an error: doesn't match the schema: Error at \"/permissions\":JSON value is not one of the allowed values, internal=Request body has an error: doesn't match the schema: Error at \"/permissions\":JSON value is not one of the allowed values\nSchema:\n {\n \"enum\": [\n \"Prescriber\",\n \"Admin\",\n \"Clinician\"\n ],\n \"items\": {\n \"type\": \"string\"\n },\n \"type\": \"array\"\n }\n\nValue:\n [\n \"Admin\"\n ]\n"
It seems like it is comparing the array
["Admin"]
vs iterating through the array on line:kin-openapi/openapi3/schema.go
Lines 641 to 656 in 989d00f
The text was updated successfully, but these errors were encountered: