Skip to content

Error when building validation schema that references another schema added from ancestor level #230

@FerrielMelarpis

Description

@FerrielMelarpis

Prerequisites

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

Fastify version

5.3.3

Plugin version

5.1.0

Node.js version

22

Operating system

macOS

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

Darwin 24.5.0

Description

Hi there!

First of all, thanks for the plugin.

I am encountering an error when I'm trying to move out my schema definitions outside of my route plugin. I wanted to move them out to be able to share them in other route plugins but I'm getting this error:

Unable to dereference schema with $id ...

This also happens even when you use fastify-plugin to wrap the plugin that defines the shared schemas.

Link to code that reproduces the bug

https://github.com/FerrielMelarpis/fastify-typebox-issue-repro

Expected Behavior

I should be able to define the shared schemas outside of my route plugins and reference them via Type.Ref.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions