-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maximum call stack size exceeded #482
Comments
I'm facing the same. Any update on this? EDIT: My issue was that it was getting into circular references because two types (one of which was included through a remote JSON schema) had the same definition name. I just added different titles to them and it worked fine for me. |
I also ran into this and traced it down to the minimum reproducible example: export const input = {
definitions: {
logical: {
oneOf: [
{
type: 'string',
description: 'oneOf string',
},
{
type: 'object',
description: 'oneOf object',
properties: {
not: {
description: 'THIS IS PROBLEMATIC',
$ref: '#/definitions/logical',
},
},
},
],
},
},
properties: {
workflows: {
type: 'object',
description: 'workflows object',
properties: {
when: {
description: 'workflows when',
$ref: '#/definitions/logical',
},
},
},
},
type: 'object',
} After experimenting with the test suite, I identified that the issue is that when the recursive reference has a However, if the Note that it also works if the top level For anyone who wants to workaround this on the circleci config schema, you can do the following: import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { compile } from "json-schema-to-typescript";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const resp = await fetch("https://json.schemastore.org/circleciconfig.json");
const schema = await resp.json();
// Update the id, since it is used to generate the base type.
schema["$id"] = "CircleCIConfig";
// Assist json-schema-to-typescript by giving the problematic definition a title.
schema.definitions.logical.title = "logical";
const types = await compile(schema, "CircleCIConfig", {
strictIndexSignatures: true,
});
fs.writeFileSync(path.join(__dirname, "circleci.d.ts"), types); Note however that although this runs generation to completion, the resulting code is not compilable as it runs into #559 , so that patch is also required to get the circleci config to work. |
@yorinasub17 just wanted to follow-up and say I ran into the same issue with the following openapi doc: "Butler_API_Entities_Project": {
"type": "object",
"properties": {
"slug": {
"type": "string"
},
"owner": {
"type": "string"
},
"parent_project": {
"$ref": "#/components/schemas/Butler_API_Entities_Project"
},
"name": {
"type": "string",
"description": "Project Name"
},
},
} As you can see the
EDIT: Ah just realized that |
When running against the CircleCI configuration schema here,
https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/circleciconfig.json a max call stack size error is thrown.
This seems to be caused by the circular references on the
logical
definitions within the schema.Using version 11.0.2 of json-schema-to-typescript
The text was updated successfully, but these errors were encountered: