Closed thorhj closed 1 year ago
Does swagger really expect zod schemas?
@kibertoad
@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: https://github.com/fastify/fastify-swagger/issues/727#issuecomment-1618258696
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 If you could test #752 and check if it solves your issue, I could easier approve. Personally I dont have a clue because I dont use zod etc..
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