Skip to content

Conversation

@luqasn
Copy link

@luqasn luqasn commented Nov 23, 2025

Changes

This PR introduces a new option that makes it possible to request that non-required parameters still be generated as non-optional (no question token) if they have a default value set in their schema.

This allows to generate types for certain server implementation use where the default value is injected automatically for the handling function to consume (I am working on one atm) and the signature on the handler should indicate that the value can not be undefined.

This makes it so that the default value can be derived and set by the framework from the openapi spec and does not need to be repeated by the person implementing the operation.

Fixes #2319

Checklist

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

@luqasn luqasn requested a review from a team as a code owner November 23, 2025 13:12
@luqasn luqasn requested a review from duncanbeevers November 23, 2025 13:12
@netlify
Copy link

netlify bot commented Nov 23, 2025

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 5d314f4

@changeset-bot
Copy link

changeset-bot bot commented Nov 23, 2025

🦋 Changeset detected

Latest commit: 5d314f4

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

This PR includes changesets to release 2 packages
Name Type
openapi-typescript Minor
swr-openapi Major

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

@luqasn luqasn force-pushed the optional-param-with-default branch from 7eb397e to 3f0607e Compare November 23, 2025 13:15
@luqasn
Copy link
Author

luqasn commented Nov 23, 2025

Test failure seems unrelated, docly have refactored their tests and moved a bunch of files: Redocly/redocly-cli@cf26d60#diff-819418d7530fd6a1220968de72601d679939eb5a01c3b9cc9e388050bd58ff77

@luqasn luqasn force-pushed the optional-param-with-default branch from f3dcc2e to 0f11d02 Compare November 23, 2025 15:44
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.

query parameters with default value are marked as optional

1 participant