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

Avoid adding undefined to the index signature for additionalProperties #1295

Conversation

pvanagtmaal
Copy link
Contributor

@pvanagtmaal pvanagtmaal commented Aug 11, 2023

Changes

Fixes #1267 and #1018

How to Review

A slightly tricky part about this is that we need to account for objects with not all properties required. In that case, we still need to add undefined to the index signature to avoid TypeScript errors

Checklist

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

@changeset-bot
Copy link

changeset-bot bot commented Aug 11, 2023

🦋 Changeset detected

Latest commit: c55a396

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openapi-typescript Minor

Not sure what this means? Click here to learn what changesets are.

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

@pvanagtmaal pvanagtmaal force-pushed the feat/avoid-undefined-on-additional-properties branch from 9169509 to c55a396 Compare August 11, 2023 17:32
@drwpow
Copy link
Contributor

drwpow commented Aug 14, 2023

This is great—thank you! I admit I was wrong on this original decision, and this is a better path forward for this library.

I do agree that a minor version is best—this is more than a patch change. But I don’t think it would technically be a breaking change and it doesn’t feel right for a major version.

}`);
});

test("additionalProperties with partly required properties", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏 great tests!

@drwpow drwpow merged commit 99a1648 into openapi-ts:main Aug 14, 2023
6 checks passed
@github-actions github-actions bot mentioned this pull request Aug 14, 2023
@drwpow
Copy link
Contributor

drwpow commented Aug 14, 2023

Released in v6.5.0!

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 this pull request may close these issues.

Generated type of additionalProperties values should not include undefined
2 participants