Skip to content

Help聽#1085

Open
Open

Description

@scotty-rdn

馃挰 Question here

I feel like this should be covered somewhere in documentation, but if it is I keep missing it.

I'm trying to use Fastify, TypeBox, and FastifyTypeBoxProvider.

I create my schemas. If I pass the Schema directly to the route() method, the types are provided successfully in the handler

Image

However, if I try to add the schema to the Fastify Instance and reference it there, it no longer works.

Image

I am also using @fastify/swagger and @fastify/swagger-ui, and that is being generated with the type references intact.

Is this just not something that can be supported by TypeBoxTypeProvider?

Your Environment

  • node version: 22
  • fastify version: "^5.2.1"
  • os: Mac

Activity

  1. Eomm commented on Mar 15, 2025

    @Eomm
    Member

    Is this just not something that can be supported by TypeBoxTypeProvider?

    No, TypeBoxTypeProvider does not support it. I think it is related to this issue: fastify/fastify-type-provider-typebox#86

    Note that the $ref are evaluated at runtime, and to provide such a feature the IDE should:

    • inspect all your schemas in the source code
    • choose the right one (what if multiple schemas have the same id?)
    • provide the autocompletion

    From the source code point of view, the plain {$ref: 'something'} does not provide any value to the reusability over the fastify.getSchema('something')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions