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

fix(openapi-typescript): correct generated type when using prefixItems #1893

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

zyoshoka
Copy link

Changes

Closes #1892

How to Review

Note that this PR also adds support for unevaluatedItems, which was supported in OAS 3.1.0.

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

@zyoshoka zyoshoka requested a review from a team as a code owner August 31, 2024 08:49
Copy link

changeset-bot bot commented Aug 31, 2024

⚠️ No Changeset found

Latest commit: 909f214

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

Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

Thank you for opening this PR, and fixing the generation. I agree that this is probably the more “correct” solution to what was originally implemented. But this would be a breaking change for people, because the original implementation (whether intentionally or not) essentially ignored items.

We’ll accept the PR as-implemented, but we’ll need to make this an opt-in feature flag, for now. In the next breaking release we can look into changing the default behavior to match this (which I strongly think we will). But I don’t want to release a new major version now just for this change and this change alone.

Would you be willing to put this behind an opt-in flag?

@@ -179,7 +245,7 @@ describe("transformSchemaObject > array", () => {
{
given: {
type: "array",
items: { type: "number" },
items: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

This specifically is the breaking change I’m referring to—we’ll need to ensure that the original test case of items: { type: "number" } stays tested, and it generates the same output. While we’re on version 7.x this can’t change (and we can revisit it when it’s time to release 8.x).

In general, modifying an original test is a good hint that it may be a breaking change.

@@ -45,6 +45,72 @@ describe("transformSchemaObject > array", () => {
want: `[
number,
number,
number,
...number[]
Copy link
Contributor

Choose a reason for hiding this comment

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

This other modification to an existing test may also technically be a breaking change, but I think because it’s purely additive, could be considered a bugfix. I would be OK with this going in as-is.

@drwpow drwpow added the openapi-ts Relevant to the openapi-typescript library label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openapi-ts Relevant to the openapi-typescript library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect type when using prefixItems
2 participants