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

Support schemas with array of types #1017

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

MarcL01
Copy link
Contributor

@MarcL01 MarcL01 commented Nov 7, 2024

Description

Support an array of schema types (IE string & null)

Motivation and Context

  • We are trying to switch away from readme.com which supports array of schema types

How Has This Been Tested?

Used the pet store demo to test - http://localhost:3000/petstore_versioned/1.0.0/update-pet-with-form

type:
  - string
  - 'null'
"type": [
  "string",
  "null"
]

Before the above schemas would result in stringnull, now they result in string | null

Screenshots (if appropriate)

Before:
Screenshot 2024-11-07 at 1 14 30 PM

After:
Screenshot 2024-11-07 at 12 54 41 PM

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes if appropriate.
  • All new and existing tests passed.

Copy link

github-actions bot commented Nov 8, 2024

Visit the preview URL for this PR (updated for commit 1a68f26):

https://docusaurus-openapi-36b86--pr1017-4gdj0s5q.web.app

(expires Sun, 08 Dec 2024 16:35:37 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

@sserrata
Copy link
Member

sserrata commented Nov 8, 2024

Hi @MarcL01, thanks for the PR. I think this is only officially supported in OpenAPI 3.1, according to the spec? How do you see this interacting with nullable or OpenAPI 3.0 in general?

@sserrata sserrata changed the title Fix schemas with multiple types Support schemas with array of types Nov 8, 2024
@sserrata sserrata added the enhancement New feature or request label Nov 8, 2024
@sserrata sserrata merged commit 6e55849 into PaloAltoNetworks:main Nov 8, 2024
11 checks passed
@robbieaverill
Copy link
Contributor

robbieaverill commented Nov 28, 2024

@sserrata OpenAPI 3.1 actually removes nullable (from 3.0) entirely - see https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0 -> "Swap nullable type for arrays".

This PR is good but we also need to add support for it in anyOf, allOf, oneOf, etc, as well in the type definitions.

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

Successfully merging this pull request may close these issues.

3 participants