Skip to content

requestBody fields optional even with defaults #1681

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

Merged
merged 3 commits into from
Jun 19, 2024

Conversation

fitztrev
Copy link
Contributor

@fitztrev fitztrev commented May 27, 2024

Changes

Noticed that when a request body field had a default value, that it was being specified as required. This would change it to be treated like a parameter with a default value.

How to Review

Let me know if the premise correct and then I could look into updating the tests.

Checklist

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

Copy link

changeset-bot bot commented May 27, 2024

⚠️ No Changeset found

Latest commit: 71a6e52

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

@drwpow
Copy link
Contributor

drwpow commented Jun 3, 2024

I think this is an improvement, thank you! Yes if you update the tests and it’s clear there are no breakages I’d be open to this change.

@drwpow
Copy link
Contributor

drwpow commented Jun 11, 2024

This looks great, thanks again! Examples updated makes sense, too.

To merge this, would love to add a test, maybe in request-body-object.test.ts. The changes to the examples look correct, but those don’t always get checked for every single change so a unit test would ensure this doesn’t regress in the future. Great work!

@fitztrev
Copy link
Contributor Author

Thanks! Good call, added a test

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.

Amazing! Thank you 🙏

@drwpow drwpow merged commit 96bdf10 into openapi-ts:main Jun 19, 2024
6 checks passed
@fitztrev fitztrev deleted the optional-request-body branch June 19, 2024 17:13
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.

2 participants