Closed giabao1008 closed 9 months ago
Can provide a PR please?
i cant, please help
Remove routePrefix: '/swagger-docs',
as you show in your example.
.register(swagger, {
swagger: {
info: {
title: 'Test swagger',
description: 'testing the fastify swagger api',
version: '0.1.0',
},
basePath: '/',
consumes: ['application/json'],
host: 'localhost',
swagger: '2.0',
},
// exposeRoute: true,
// routePrefix: '/swagger-docs',
});``
yes, i removed but, seem the path /documentation not work
Please read migration.md
one more question, i ve connected swagger to fastify with swagger ui, define a router with schema, but in swagger doc, it not auto generated
this is my config
await fastify.register(fastifySwagger, {
swagger: {
info: {
title: ' Swagger',
description: 'Testing swagger API',
version: '0.1.0',
},
host: `${HOST}:${PORT}`,
schemes: ['http'],
consumes: ['application/json'],
produces: ['application/json'],
swagger: '2.0',
},
});
await fastify.register(fastifySwaggerUi, {
routePrefix: '/v1/example/docs',
initOAuth: {},
uiConfig: {
docExpansion: 'full',
deepLinking: false,
},
uiHooks: {
onRequest: function (request, reply, next) {
next();
},
preHandler: function (request, reply, next) {
next();
},
},
staticCSP: true,
transformStaticCSP: (header) => header,
});
and router
fastify.get(
'/',
{
schema: {
description: 'This is an endpoint for fetching all users',
tags: ['users'],
response: {
200: {
description: 'Success Response',
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'number' },
name: { type: 'string' },
age: { type: 'number' },
createdAt: { type: 'string' },
updatedAt: { type: 'string' },
},
},
},
},
},
},
async function (request: FastifyRequest, reply: FastifyReply) {
return fastify.exampleService.getAll();
}
);
please advise me
you need both fastify-swagger and fastify-swagger-ui
you need both fastify-swagger and fastify-swagger-ui
yes, i have
Please share full config then
Please share full config then
please see above, it's my all configs, or what else ?
Please share full config then
please see above
here you have a fully working example https://github.com/borjatur/clean-architecture-fastify-mongodb/blob/master/src/infrastructure/http/plugins/docs.ts
hope that can help you
I tried the same and was unable to generate docs automatically for my APIs. Any update here?
Everything is working fine for me, so it would be useful to have a reproduction.
I copy-pasted the docs.ts file and even didn't get any page
I copied and pasted examples from the documentation, and everything is functioning well: GitHub Link.
Similarly, I replicated the contents of the docs.ts file from @borjatur's example, and it is also working smoothly: GitHub Link.
If there are problems then please open a new issue.
Prerequisites
🚀 Feature Proposal
currently im working with fastify swagger and typescript, follow as example folder. but when use exposeRoute option, it will prompt error
Motivation
No response
Example