import { Type } from 'class-transformer';
import { ValidateNested } from 'class-validator';
export class Test {
@Type(() => Test)
@ValidateNested()
sub: Test;
}
Error thrown
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'properties' -> object with constructor 'Object'
--- property 'sub' closes the circle
at JSON.stringify (<anonymous>)
at Object.<anonymous> (node_modules/koa2-swagger-ui/dist/index.js:59:57)
at Object.wrapper (node_modules/handlebars/dist/cjs/handlebars/internal/wrapHelper.js:15:19)
at Object.eval [as main] (eval at createFunctionContext (node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:262:23), <anonymous>:21:102)
at main (node_modules/handlebars/dist/cjs/handlebars/runtime.js:208:32)
at ret (node_modules/handlebars/dist/cjs/handlebars/runtime.js:212:12)
at ret (node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:519:21)
at koaSwaggerUi (node_modules/koa2-swagger-ui/dist/index.js:73:24)
at dispatch (node_modules/koa-compose/index.js:42:32)
at node_modules/koa-compose/index.js:34:12
What happened?
Sample code
Error thrown
What I want?
Render 2 levels for Nested structure based on
JSON.stringify()
replacer.