-
-
Notifications
You must be signed in to change notification settings - Fork 208
Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
Plugin version
n/a
Node.js version
16.13.1
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
10
Description
Hi. I'm currently looking at recursive schema composition in TypeBox, and have been carrying out a few tests in Fastify. Have run into an issue in fast-json-stringify where it seems unable to locate a previously defined identifier for an inline (non-external) reference.
Also may have picked up on a small type error where $id is not a valid property which makes passing top level $id for general schemas not possible.
Related Issue
Steps to Reproduce
The following is the minimal repro replicating the following schema type.
interface Node {
id: string
nodes: Node[]
}import fastJson from 'fast-json-stringify'
const stringify = fastJson({
"$id": "Node",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"nodes": {
"type": "array",
"items": {
"$ref": "Node"
}
}
},
"required": [
"id",
"nodes"
]
})Results in the following error
schema = externalSchema[ref[0]];
^
TypeError: Cannot read properties of undefined (reading 'Node')
Expected Behavior
fast-json-stringify should be able to accept schemas of this form.
Metadata
Metadata
Assignees
Labels
No labels
