-
- Notifications
You must be signed in to change notification settings - Fork 239
Open
Description
What works
The given schema
{ "$id": "recursive.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { "label": { "anyOf": [ { "type": "integer" } ] }, "value": { "$ref": "#" } }, "title": "RecursiveType", "type": "object" }gives the resulting JS object which is properly circular right away (object > [Circular])
<ref *1> { '$id': 'recursive.json', '$schema': 'https://json-schema.org/draft/2020-12/schema', properties: { label: { anyOf: [ { type: 'integer' } ] }, value: [Circular *1] }, title: 'RecursiveType', type: 'object' }What doesn't work
Change the reference to be by name instead of just #
{ "$id": "recursive.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { "label": { "anyOf": [ { "type": "integer" } ] }, "value": { "$ref": "recursive.json" } }, "title": "RecursiveType", "type": "object" }This instead gives the following TS. Note that it's the same as above EXCEPT it's expanded one level too deep object > object > [Circular]
{ '$id': 'recursive.json', '$schema': 'https://json-schema.org/draft/2020-12/schema', properties: { label: { anyOf: [ { type: 'integer' } ] }, value: <ref *1> { '$id': 'recursive.json', '$schema': 'https://json-schema.org/draft/2020-12/schema', properties: { label: { anyOf: [ { type: 'integer' } ] }, value: [Circular *1] }, title: 'RecursiveType', type: 'object' } }, title: 'RecursiveType', type: 'object' }Metadata
Metadata
Assignees
Labels
No labels