Operation description and summary
Closed this issue · 4 comments
First of all, thank you for a wonderful library. Solves the exact issue I was having gluing together a bunch of disparate solutions.
Is there a way to add a description and summary to an endpoint?
Hey there, thanks for the kind words!
fastify-zod-openapi/examples/openapi.ts
Line 78 in 55cf90a
You can define a description
and summary
here on the same level as content
, but it looks like fastify-swagger
swallows up the summary
field. You'd need to raise a PR somewhere around here
Ah I see, my mistake, the operation.... 🙈
You should be able to declare them under the schema
section.
fastify-zod-openapi/examples/openapi.ts
Line 51 in 55cf90a
eg.
app.withTypeProvider<FastifyZodOpenApiTypeProvider>().route({
method: 'POST',
url: '/:jobId',
schema: {
description: 'hello', // <- HERE
summary: 'world', // <- AND HERE
params: z.object({
foo: z.string().openapi({
description: 'path parameter example',
example: 'bar',
}),
}),
response: {
200: z.object({
jobId: JobIdSchema,
}),
201: {
content: {
'application/json': {
example: { jobId: '123' },
schema: z.object({
jobId: z.string().openapi({
description: 'Job ID',
example: '60002023',
}),
}),
},
},
},
},
} satisfies FastifyZodOpenApiSchema,
handler: async (_req, res) =>
res.send({
jobId: '60002023',
}),
});
There should hopefully be some intellisense types in there for you to use
Wonderful, thank you! Sending a coffee your way