Support circular schema definitions
Stefano31 opened this issue · 1 comments
Stefano31 commented
First of all, great job.
I have tried to use this library but in a test case I have found a problem with the circular schema.
To Reproduce
Use any circular schema, here an example:
// file tree.oas.ts
// Open API Specification
export default {
openapi: "3.0.3",
info: {
version: "1",
title: "Tree - OpenAPI 3.0",
description:
"This is a sample of tree",
termsOfService: "http://swagger.io/terms/",
},
paths: {
"/tree": {
get: {
tags: ["tree"],
summary: "Get tree",
description: "",
operationId: "getTree",
responses: {
"200": {
description: "successful operation",
content: {
"application/json": {
schema: {
$ref: "#/components/schemas/Node",
},
},
},
},
"404": {
description: "Tree not found",
},
},
},
},
},
components: {
schemas: {
Node: {
type: "object",
properties: {
number: {
type: "integer",
format: "int64",
example: 10,
},
child: {
$ref: "#/components/schemas/Node",
},
},
},
},
},
} as const;
// file client.ts
import { createClient, Mutable } from 'fets'
import treeOAS from './tree.oas'
const client = createClient<Mutable<typeof treeOAS>>()
const response = await client['/tree'].get() // <--- HERE THERE IS AN ERROR TS2615 (circular reference for field "child")
const body = await response.json()
console.log(body)
Expected behavior
Honestly, I don't know how to works deeply this library and I'm trying to understand, but I think that should be there a flag that avoids these scenarios with circular reference
Environment:
package-name...
: fets- NodeJS: 18