Skip to content

Supporting $ref in FromSchema #1180

Answered by sinclairzx81
jrabausch asked this question in Q&A
Discussion options

You must be logged in to vote

@jrabausch Hi,

Would it be possible to support $refs and definitions? How would you go about that?

TypeBox has support for $ref and $defs schematics via Type.Module. However be mindful that Modules are very constrained and may not be suitable for all cases. Below is how you might approach creating definition schematics (using FromSchema (which I've just pushed an update for to handle $ref, so be sure to grab the latest prototype))

Additional Information on Modules Here

import { Type, Static } from '@sinclair/typebox'
import { FromSchema } from './prototypes' // from prototypes

// Modules act as containers for multiple types. TypeBox 
// uses modules to enable remote referential computa…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jrabausch
Comment options

Answer selected by jrabausch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1179 on February 19, 2025 10:14.