swagger-ui: Maximum call stack size exceeded of complicated schemas (FHIR for example)
On large schemas, Swagger UI either fails with RangeError: Maximum call stack size exceeded error or hangs with 100% CPU usage. In my case, these were the official FHIR schemas which may be downloaded by a link: https://www.hl7.org/fhir/fhir.schema.json.zip It would be enough to unzip them and copy the fhir.schema.json folder next to your swagger spec.
| Q | A |
|---|---|
| Bug or feature request? | A bug |
| Which Swagger/OpenAPI version? | dunno |
| Which Swagger-UI version? | 3.13.0-3.13.2 |
| How did you install Swagger-UI? | Either with webjars or downloaded the release zip archive. |
| Which browser & version? | Chrome 65.0.3325.181 (64-bit), FF 57.0.4 (64-bit) |
| Which operating system? | Mac OS 10.11.6 |
Demonstration API definition
{"swagger": "2.0",
"schemes": ["http"],
"info": {"contact": {"email": "test@test.com"},
"title": "sdfsdfsf"},
"paths": {"/foo": {"get": {"description": "sdfsdfsdfdsf",
"responses": {200: {"description": "sdfsdf",
"schema": {"$ref": "./fhir.schema.json/Practitioner.schema.json"}}}
}}}}
Configuration (browser query string, constructor, config.yaml)
I didn’t change enything except the url parameter: url: "/swagger/schema",
Expected Behavior
To see the schemas.
Current Behavior
Either an exception (3.13.0) or an endless 100% CPU usage (3.13.2)
Context
I figured out by crafting a small subset of definitions out of these schemas.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 38 (34 by maintainers)
Commits related to this issue
- Reproducing circular structure https://github.com/swagger-api/swagger-ui/issues/4411#issuecomment-405611253 — committed to heldersepu/hs-scripts by heldersepu 6 years ago
Latest version seems to have fixed all the issues I encountered before:
http://petstore.swagger.io/?url=http://swagger-net-test.azurewebsites.net/api/NestedSwag/5 Everything expand significantly faster than before
http://petstore.swagger.io/?url=https://raw.githubusercontent.com/heldersepu/hs-scripts/master/swagger/4411_swagger.json#/default/get_foo The get still takes a few seconds to fully expand but it does expand with no issues
@shockey you can close this issue