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

Included types break usage of config object #784

Open
2 tasks done
tmcw opened this issue Feb 22, 2024 · 1 comment
Open
2 tasks done

Included types break usage of config object #784

tmcw opened this issue Feb 22, 2024 · 1 comment

Comments

@tmcw
Copy link

tmcw commented Feb 22, 2024

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.26.x

Plugin version

8.14.x

Node.js version

20.x

Operating system

Linux

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

All

Description

The config object for routes in fastify is typed liberally: it is a union with unknown and you can use it to store arbitrary configuration. However, this module specifies a concrete type for the config option that breaks extensions:

interface FastifyContextConfig {
swaggerTransform?: SwaggerTransform | false;
}

Steps to Reproduce

import Fastify from 'fastify';
import swagger from '@fastify/swagger';

const fastify = Fastify();

fastify.route({
  url: '/',
  config: { output: 'hello world!' },
  method: 'GET',
  handler(req, reply) {
    reply.send({ hello: 'world' });
  },
});

fastify.listen({ port: 3000 });

Online repro: https://stackblitz.com/edit/node-59kmye?file=package.json,index.ts

Expected Behavior

It should be possible to use fastify-swagger without overwriting config types.

@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

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

2 participants