-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
Endpoint-specific schema transform #749
Comments
Does swagger really expect zod schemas? |
@Uzlopak not swagger per se, but if type-provider-zod compiler and validator are registered, that will be the format of schemas that they will expect |
By the way, if you think this is a good idea and if we make a design for the interface (there are probably opinions on my suggestion), I could work on this feature myself. |
@mcollina Suggested this API: #727 (comment) |
I really need this feature as well, for a project using zod type provider, as a alternative schema parser. Is this being shipped in the next version, or what's the status of it? 🤔 |
@fredrikj31 |
I have tried pulling it down, and using it on a fastify server with zod type provider, and it seems to be working, so it looks like it solves my problem. Can this be released so I can use it on my apis? |
I reviewed it now. Waiting for feedback by @thorhj |
Okay, super. Thanks for the status update. Will be watching the PR 🙏 |
Is there any update to this? I can see that the PR has been merged in. |
shipped v8.10.0 |
Prerequisites
🚀 Feature Proposal
fastify-swagger allows choose a transform function in case you have a different schema type than the built-in one.
You can have different schema types for different endpoints, but to my knowledge fastify-swagger does not support this (I couldn't find anything for this at least). I would like to have an endpoint-specific transform function that differs from the "global" transform function. Something like this is what I imagine:
This
swaggerTransform
property should be able to indicate the "default" (no) transform or any other transform function.Motivation
In some of my projects I am fastify-type-provider-zod which has its own transform function for this use-case.
However, I have found a need for having a specific endpoint NOT using zod schemas to define the schema. In my case, we would like to use a plugin that adds a new route-shorthand to fastify to easily create AWS SNS event webhooks correctly, and in this plugin the schema is implemented using the default schema declaration. When mixing schema types in the project, fastify-swagger will fail because it expects the routes to have zod schemas, but this one endpoint does not.
My current workaround is to hide the endpoint in question from swagger, but I would like to have it included, and to do that I think I need an endpoint-specific transform function for the endpoints in question.
Example
No response
The text was updated successfully, but these errors were encountered: