Skip to content

Conversation

@yy4382
Copy link

@yy4382 yy4382 commented Sep 19, 2025

The resolver function takes in a options parameter, and passed it to both toJsonSchema and toOpenAPISchema. However these two functions actually expects two different shapes of the options. For toJsonSchema, the options is directly passed to the underlaying schema lib. But for toOpenAPISchema, it takes in { component, options }, and the latter sub-options is passed to the actual schema libs.

The test i added is a good example of the use case that requires user to pass options to underlaying lib (in this example, zod), and shows how the new interface should be used.

The current API design is far from perfect, but this is the best solution I can think of to avoid breaking changes.

The `toOpenAPISchema` from `@standard-community/standard-openapi`'s second parameter takes in { component, options }, and the latter `options` is passed to the actual schema libs.
@MathurAditya724
Copy link
Member

Thank you for this, I was also thinking about this lately. Let me try to draft a new API for this, if not then we can move with this one.

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