-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
Describe the bug
I have an API method which returns a tree structure. I created a definition file with describing the recursive type in JSON schema and I tried this code generator. And the generator instantly hung.
To Reproduce
Steps to reproduce the behavior:
- Put the following JSON content as
openrpc.json
in your current directory npm i @open-rpc/generator
npx open-rpc-generator init
- The command hangs at the first question.
npx open-rpc-generator generate
hangs as well
{
"openrpc": "1.3.2",
"info": {
"version": "0.0.0",
"title": "My API"
},
"methods": [
{
"name": "getTree",
"description": "",
"params": [],
"result": {
"name": "tree",
"description": "",
"schema": { "$ref": "#/components/schemas/Node" }
}
}
],
"components": {
"schemas": {
"Node": {
"type": "object",
"properties": {
"id": { "type": "integer" },
"children": {
"type": "array",
"items": { "$ref": "#/components/schemas/Node" }
}
}
}
}
}
}
Expected behavior
The npx open-rpc-generator init
creates a configuration file for the project.
Screenshots
Instead of screenshot I captured terminal screen outputs:
> npx open-rpc-generator init
? Where is your OpenRPC document? May be a file path or url. (openrpc.json)
The command hung at the first question.
Desktop (please complete the following information):
@open-rpc/generator
: v1.22.3- OS: Windows 10
- Browser: N/A
- Version: Node.js v18.20.0
Additional context
When I modified the children
field as follows, this issue didn't occur.
"children": {
"type": "array",
"items": { "type": "object" }
}
I believe the recursive type made the generator hang. I guess the generator checks $ref
recursively without checking the reference is already visit.
zcstarr and Stankyezcstarr
Metadata
Metadata
Assignees
Labels
No labels