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

fix: openapi/swagger options path #768

Merged

Conversation

gmatheus
Copy link
Contributor

Hello! I've started using this plugin and noticed some unexpected behavior while trying to use openapi config on fastify.register. I've tried to include openapi.paths config following your options documentation (OpenAPI configuration) in order to include some additional paths to my Swagger object, but it had no effect. This PR fixes it.

Here's an example of what I'm trying to do with openapi.paths:

await fastify.register(fastifySwagger, {
  prefix: '/docs',
  openapi: {
    info: {
      title: 'Fastify sample server',
      description: 'Fastify sample api',
      version: '0.1.0',
    },
    paths: {
      '/status': {
        get: {
          description: 'Status route, so we can check if server is alive',
          tags: [
            'Status',
          ],
          responses: {
            200: {
              description: 'Server is alive',
              content: {
                'application/json': {
                  schema: {
                    type: 'object',
                    properties: {
                      health: {
                        type: 'boolean',
                      },
                      date: {
                        type: 'string',
                      },
                    },
                    example: {
                      health: true,
                      date: '2018-02-19T15:36:46.758Z',
                    },
                  },
                },
              },
            },
          },
        },
      },
    },
  },
})

I've also fixed it in swagger part since Swagger configuration also accepts a paths object.

Checklist

Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

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

LGTM

@gmatheus
Copy link
Contributor Author

LGTM

@Uzlopak thanks for your review and thanks to @mcollina for re-running the checks!

Do you consider merging this one and releasing a new package version soon? This fix will be really useful in a project my team is working on.

@Uzlopak Uzlopak merged commit 5277980 into fastify:master Nov 27, 2023
19 checks passed
@Uzlopak
Copy link
Contributor

Uzlopak commented Nov 27, 2023

@fastify/leads
Can you please release?

@gmatheus gmatheus deleted the fix/options-openapi-swagger-path/gmatheus branch November 28, 2023 20:19
@gmatheus
Copy link
Contributor Author

gmatheus commented Dec 4, 2023

Guys, any updates on the next release with this fix?

@Eomm
Copy link
Member

Eomm commented Dec 4, 2023

done

thanks for the ping 👍🏼

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.

3 participants