Skip to content
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

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

Merged
merged 3 commits into from
Jul 4, 2023
Merged

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

merged 3 commits into from
Jul 4, 2023

Conversation

Liam-Tait
Copy link
Contributor

@Liam-Tait Liam-Tait commented Jul 4, 2023

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

@Liam-Tait Liam-Tait marked this pull request as ready for review July 4, 2023 04:03
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit 5c84c4d into fastify:master Jul 4, 2023
@samchungy
Copy link
Contributor

Love your work mate cheers @Liam-Tait

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose swagger/openapi version for transform hook Add ability to filter by version constraint
3 participants