fastify / fastify-swagger

Swagger documentation generator for Fastify
MIT License
910 stars 200 forks source link

feat: add route, openapi and swagger objects to transform #739

Closed Liam-Tait closed 1 year ago

Liam-Tait commented 1 year ago

Add route, openapiObject, and swaggerObject to the transform hook parameters.

Keeps schema and url as param to avoid breaking changes

// openapi
await fastify.register(fastifySwagger, {
  openapi: {},
  transform: ({ schema, url, route, openapiObject }) => {
    // do something with openapiObject
    // do something with route e.g route.constraints.version
    return {
      schema: route.schema,
      url: route.url
    }
  }
})
await fastify.register(fastifySwagger, {
  swagger: {},
  transform: ({ schema, url, route swaggerObject }) => {
    // do something with swaggerObject
    return { schema, url }
  }
})

closes #737 access to version via openapiObject.openapi or swaggerObject.swagger closes #732 access to route version via route.constraints.version

Checklist

samchungy commented 1 year ago

Love your work mate cheers @Liam-Tait