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

not assignable to type 'FastifySchema' #642

Closed
2 tasks done
normowl opened this issue Jul 30, 2022 · 1 comment
Closed
2 tasks done

not assignable to type 'FastifySchema' #642

normowl opened this issue Jul 30, 2022 · 1 comment

Comments

@normowl
Copy link

normowl commented Jul 30, 2022

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.3.0

Plugin version

7.4.1

Node.js version

18.4

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

12.4

Description

I have a route protected by bearer token and I would like swagger to capture this in the documentation. The route is defined as such:

async function routes(fastify: FastifyInstance) {
  fastify.get(`/users`, {
    onRequest: [fastify.authenticate],
    schema: {
      security: [
        {
          "apiKey": []
        }
      ]
    }
  },

However the compiler complains about error TS2322: Type '{ security: { apiKey: never[]; }[]; }' is not assignable to type 'FastifySchema'

Steps to Reproduce

Apply the schema.security property to fastify routes as per the readme https://github.com/fastify/fastify-swagger

Expected Behavior

No response

@normowl
Copy link
Author

normowl commented Jul 30, 2022

Similar issue fastify/fastify#4122

Looks like I needed to do an extra step to register my types.

@normowl normowl closed this as completed Jul 30, 2022
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

No branches or pull requests

1 participant