openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

requestBody fields optional even with defaults

Open fitztrev opened this issue 1 year ago • 1 comments

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)

fitztrev avatar May 27 '24 04:05 fitztrev

⚠️ No Changeset found

Latest commit: 71a6e5292d63b7b4cead2aec3321c00dc5cf7566

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

changeset-bot[bot] avatar May 27 '24 04:05 changeset-bot[bot]

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 avatar Jun 03 '24 19:06 drwpow

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!

drwpow avatar Jun 11 '24 15:06 drwpow

Thanks! Good call, added a test

fitztrev avatar Jun 11 '24 21:06 fitztrev