Skip to content

Support v3.1 typed arrays #1167

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Thomasdezeeuw
Copy link

In OpenAPI v3.1 the nullable property was replaced with a "typed array", that is an array that can either be of type T or null.

To make the minimal amount of changes this commit converts a type array back into what a 3.0 parser would expect.

Closes #991

In OpenAPI v3.1 the nullable property was replaced with a "typed array",
that is an array that can either be of type T or null.

To make the minimal amount of changes this commit converts a type array
back into what a 3.0 parser would expect.

Closes acacode#991
Copy link

changeset-bot bot commented Apr 10, 2025

⚠️ No Changeset found

Latest commit: f1988f6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@smorimoto smorimoto added the enhancement New feature or request label Apr 11, 2025
@Thomasdezeeuw
Copy link
Author

@smorimoto any chance you could review this? We could really use this change.

@smorimoto smorimoto requested a review from Copilot April 24, 2025 00:10
Copilot

This comment was marked as outdated.

property.type = property.type[0];
property.nullable = true;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add also this after your condition, to type array with single type work.

if (Array.isArray(property.type) && property.type.length == 1) { property.type = property.type[0]; }

Example yaml:

SomeType:
type:
- string
enum:
- one
- two

OtherComponent:
type: object
properties:
type:
$ref: '#/components/schemas/SomeType'

@smorimoto
Copy link
Collaborator

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!


Bugbot free trial expires on September 2, 2025
Learn more in the Cursor dashboard.

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.

Nullable array with $ref is generated as any[] | null
3 participants