Skip to content
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

Structural error at [property] should be equal to one of the allowed values allowedValues: array, boolean, integer, number, object, string #15

Closed
jziggas opened this issue Mar 26, 2024 · 3 comments · Fixed by #16

Comments

@jziggas
Copy link

jziggas commented Mar 26, 2024

Hello, I was navigating through dndbeyond.com to record API requests and there are many structural errors when importing the resulting JSON into Swagger Editor similar to below:

Structural error at paths./font_picker.post.requestBody.content.application/json.schema.properties.organization_id.type
should be equal to one of the allowed values
allowedValues: array, boolean, integer, number, object, string

This particular request looks like:

curl 'https://echidna.wirewax.com/font_picker' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'origin: https://player.vimeo.com' \
  -H 'pragma: no-cache' \
  -H 'referer: https://player.vimeo.com/' \
  -H 'sec-ch-ua: "Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36' \
  --data-raw '{"environment":"player","organization_id":null}'

The resulting OpenAPI request body looks like:

requestBody:
       content:
         application/json:
           schema:
             type: object
             properties:
               environment:
                 type: string
               organization_id:
                 type: 'null'
             required:
               - environment
               - organization_id

As you can see null is not the same as 'null'. When submitting a value of null it's probably not possible to determine what the type signature should be. But rather than a string of 'null' it should probably just be an empty string to or one of the other allowed values to adhere to the spec.

@AndrewWalsh
Copy link
Owner

AndrewWalsh commented Mar 26, 2024

Hi @jziggas, have you tried importing the spec into https://editor-next.swagger.io/ ? This error may be because the editor you're using isn't compatible with the latest OpenAPI 3.1 standard.

I believe type: 'null' is correct here (OpenAPI 3.1, JSON Schema 2020-12), it was introduced in 3.1, but doesn't exist in <=3.0.

https://stackoverflow.com/questions/48111459/how-to-define-a-property-that-can-be-string-or-null-in-openapi-swagger.

@jziggas
Copy link
Author

jziggas commented Mar 26, 2024

Oh interesting, thank you. I was not aware of that URL and was using the standard https://editor.swagger.io/ one. There is only one error when pasting into that next gen editor (well I guess it is more than one considering the spaces in the key names):

image

@AndrewWalsh
Copy link
Owner

@jziggas Looks like the whitespace in the key names of securitySchemes is an issue. Fixed in v1.5.2, thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants