You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I get the following error when I try to generate an open API document for an interface that references itself or contains circular dependency with another interface.
Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'properties' -> object with constructor 'Object'
| property 'subRows' -> object with constructor 'Object'
--- property 'items' closes the circle 400
ERROR >>>> TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'properties' -> object with constructor 'Object'
| property 'subRows' -> object with constructor 'Object'
--- property 'items' closes the circle
at JSON.stringify ()
To Reproduce
You can go ahead and reproduce this with the below schema as an example. Pass this schema to deferenceSchema function
and use the dereferenced schema in the convert function. Here default_2 references itself in the subRows. Example provided below: const schema = { title: 'UserResponse', description: 'Response object for user', type: 'object', properties: { user: { $ref: '#/definitions/default_1', description: 'user details', }, }, definitions: { default_1: { type: 'object', properties: { id: { type: 'number', }, basicInformation: { type: 'object', properties: { firstName: { type: 'string', }, lastName: { type: 'string', }, email: { type: 'string', } }, }, classes: { type: 'array', items: { $ref: '#/definitions/default_2', }, }, }, }, default_2: { type: 'object', properties: { className: { type: 'string', }, details: { type: 'array', items: { $ref: '#/definitions/default_3', }, }, id: { type: 'number', }, parentId: { type: 'number', }, subRows: { type: 'array', items: { $ref: '#/definitions/default_2', }, } }, }, default_3: { type: 'object', properties: { id: { type: 'number', }, detailDesc: { type: 'string', }, detailType: { $ref: '#/definitions/default_4', } }, }, default_4: { type: 'object', properties: { detailTypeName: { type: 'string', }, detailCode: { type: 'string', }, id: { type: 'number', }, }, }, }, $schema: 'http://json-schema.org/draft-07/schema#', };
const deReferencedSchema = await dereferenceSchema(schema);
const convertedSchemas = SchemaFactory.convert(deReferencedSchema, 'UserResponse');
**Expected behavior**
It should generate the document even if the interface is self-referencing or has circular dependencies.
**Desktop (please complete the following information):**
- Serverless version: [e.g. 3.34.0]
- serverless-openapi-documenter version : 0.0.72
The text was updated successfully, but these errors were encountered:
Describe the bug
I get the following error when I try to generate an open API document for an interface that references itself or contains circular dependency with another interface.
Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'properties' -> object with constructor 'Object'
| property 'subRows' -> object with constructor 'Object'
--- property 'items' closes the circle 400
ERROR >>>> TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'properties' -> object with constructor 'Object'
| property 'subRows' -> object with constructor 'Object'
--- property 'items' closes the circle
at JSON.stringify ()
To Reproduce
You can go ahead and reproduce this with the below schema as an example. Pass this schema to deferenceSchema function
and use the dereferenced schema in the convert function. Here default_2 references itself in the subRows. Example provided below:
const schema = { title: 'UserResponse', description: 'Response object for user', type: 'object', properties: { user: { $ref: '#/definitions/default_1', description: 'user details', }, }, definitions: { default_1: { type: 'object', properties: { id: { type: 'number', }, basicInformation: { type: 'object', properties: { firstName: { type: 'string', }, lastName: { type: 'string', }, email: { type: 'string', } }, }, classes: { type: 'array', items: { $ref: '#/definitions/default_2', }, }, }, }, default_2: { type: 'object', properties: { className: { type: 'string', }, details: { type: 'array', items: { $ref: '#/definitions/default_3', }, }, id: { type: 'number', }, parentId: { type: 'number', }, subRows: { type: 'array', items: { $ref: '#/definitions/default_2', }, } }, }, default_3: { type: 'object', properties: { id: { type: 'number', }, detailDesc: { type: 'string', }, detailType: { $ref: '#/definitions/default_4', } }, }, default_4: { type: 'object', properties: { detailTypeName: { type: 'string', }, detailCode: { type: 'string', }, id: { type: 'number', }, }, }, }, $schema: 'http://json-schema.org/draft-07/schema#', };
The text was updated successfully, but these errors were encountered: