-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Problem
When using a circular reference in the OpenAPI schema, the application fails with a stack overflow error.
Details
- Creating a schema with self-referencing models (such as a
Todoclass containing a collection ofTodoas children) triggers aMaximum call stack size exceedederror. - The stack trace points to an issue in the massimo-cli's
get-type.jswhen processing the circular reference.
Steps to Reproduce
- Define a model with a circular reference:
- Generate the OpenAPI schema and attempt to use it with massimo-cli.
- Observe the error (see image below).
Error Output
Example Model
public class Todo
{
public int Id { get; set; }
public string? Name { get; set; }
public bool IsComplete { get; set; }
public ICollection<Todo>? Children { get; set; }
}Example Schema
{
...
"components": {
"schemas": {
"Todo": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"name": {
"type": "string",
"nullable": true
},
"isComplete": {
"type": "boolean"
},
"nestedTodos": {
"type": "array",
"nullable": true,
"items": {
"$ref": "#/components/schemas/Todo"
}
}
}
}
}
}
}Expected Behavior
The tool should handle circular references gracefully without crashing or exceeding the call stack size.
Actual Behavior
- Throws a
Maximum call stack size exceedederror. - Fails to process the OpenAPI schema with circular references.
Environment
- massimo-cli@0.4.0
- Node.js v22.19.0
Additional Notes
- This issue appears to be related to circular reference handling in the OpenAPI schema parser/processor.
- Other libraries, such as openapi-typescript, are able to handle circular references in OpenAPI schemas successfully. Investigating their approach might provide insights for resolving this issue.
Metadata
Metadata
Assignees
Labels
No labels