fastify-type-provider-typebox icon indicating copy to clipboard operation
fastify-type-provider-typebox copied to clipboard

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

Open FerrielMelarpis opened this issue 10 months ago • 0 comments

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] 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.

FerrielMelarpis avatar Jun 06 '25 16:06 FerrielMelarpis