swagger-api / swagger-api/swagger-ui
"Maximum call stack size exceeded" in SwaggerEditor's "Generate Client > html2" and "File > Download Resolved YAML" functions.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: Windows 11
- Browser: Chrome
- Version: 123.0.6312.60 (64 bits)
- Method of installation: SwaggerEditor
- Swagger-UI version: 3.0.54
- Swagger/OpenAPI version: OpenAPI 3.0.1
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.1
info:
title: Test API
version: v1
paths:
/v{version}/projects/{projectId}/compounds:
get:
tags:
- Compounds
summary: Get all compounds.
operationId: GetCompounds
parameters:
- name: version
in: path
description: 'API version (e.g.: 1)'
required: true
schema:
type: string
- name: projectId
in: path
description: The project id
required: true
schema:
type: integer
format: int32
example: 15
responses:
'200':
description: Success
content:
text/plain:
schema:
$ref: '#/components/schemas/ArrayJobDto'
application/json:
schema:
$ref: '#/components/schemas/ArrayJobDto'
text/json:
schema:
$ref: '#/components/schemas/ArrayJobDto'
'202':
description: Accepted
content:
text/plain:
schema:
$ref: '#/components/schemas/ArrayJobDto'
application/json:
schema:
$ref: '#/components/schemas/ArrayJobDto'
text/json:
schema:
$ref: '#/components/schemas/ArrayJobDto'
components:
schemas:
ArrayJobDto:
type: object
properties:
id:
type: string
format: uuid
status:
allOf:
- $ref: '#/components/schemas/ArrayJobDto'
error:
allOf:
- $ref: '#/components/schemas/ArrayJobDto'
nullable: true
payload:
type: array
items:
$ref: '#/components/schemas/ArrayJobDto'
nullable: true
additionalProperties: false
Swagger-UI configuration options:
N/A
N/A
Describe the bug you're encountering
Generator Client for "html2" is failing to render the schemas when they have circular references. Also, SwaggerEditor fails when trying to "Download Resolved JSON/YAML". The error shown is "Maximum call stack size exceeded".
To reproduce...
Steps to reproduce the behavior:
Scenario 1:
- Go to https://editor-next.swagger.io/ or https://editor.swagger.io/
- Paste the provided OpenAPI spec content in the corresponding area of the editor.
- Click on "Generate Client > html2" to trigger the download.
- Save the zip file in your computer and extract.
- Open index.html file.
- Open browser's console to observe the errors.
Scenario 2:
- Go to https://editor-next.swagger.io/ or https://editor.swagger.io/
- Paste the provided OpenAPI spec content in the corresponding area of the editor.
- Click on "File > Download Resolved YAML".
- Observe the error thrown by the web app.
Expected behavior
Scenario 1:
Browser's console doesn't display any "Maximum call stack size exceeded" errors, meaning that it processes Circular References correctly and schemas are rendered properly. (Consider using a dictionary of the visited nodes).
Scenario 2:
Browser throws a file to download that includes the resolved YAML file.
Screenshots
Scenario 1:
Scenario 2:
Additional context or thoughts
A similar problemas was resolved in Issue #8537, but they exclusively impacted the Editor's UI and the issue persists in (at least) this other functions. @char0n your input is greatly appreciated. The provided spec file was created specifically to replicate this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in Swagger Editor with the provided OpenAPI 3.0.1 document, first testing Generate Client > html2 and then File > Download Resolved YAML. Trace the two failing paths and verify that circular references no longer cause a maximum call stack error, the generated schemas render, and resolved YAML downloads successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- frontend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100