Skip to content
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

OpenAPI 3.1.0 support: RangeError: Maximum call stack size exceeded #8537

Closed
WilliamALiang opened this issue Mar 31, 2023 · 11 comments
Closed

Comments

@WilliamALiang
Copy link

WilliamALiang commented Mar 31, 2023

Q&A (please complete the following information)

  • OS: [macOS]
  • Browser: [chrome]
  • Version: [e.g. 22]
  • Method of installation: [e.g. npm, dist assets]
  • Swagger-UI version: [5.0.0-alpha.54]
  • Swagger/OpenAPI version: [Swagger 3.0, OpenAPI 3.1]

Content & configuration

Example Swagger/OpenAPI definition:

# your YAML here

Swagger-UI configuration options:

SwaggerUI({
  //default
})
//default

Describe the bug you're encountering

To reproduce...

Steps to reproduce the behavior:

  1. Go to 'https://editor-next.swagger.io/?_ga=2.185794858.2005013735.1680249491-2072638638.1670232233'
  2. enter openapi json
{
    "openapi": "3.1.0",
    "info": {
        "title": "API",
        "license": {
            "name": "Apache 2.0",
            "url": "https://www.apache.org/licenses/LICENSE-2.0.txt"
        },
        "version": "1.0"
    },
    "servers": [
        {
            "url": "http://192.168.0.105:11010",
            "description": "Generated server url"
        }
    ],
    "paths": {
        "/security/role-config/menu-tree": {
            "get": {
                "tags": [
                    "角色配置管理"
                ],
                "summary": "查询平台菜单树",
                "operationId": "menuTree",
                "parameters": [
                    {
                        "name": "code",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "*/*": {
                                "schema": {
                                    "$ref": "#/components/schemas/com.cacao.operation.security.model.PlatformMenuTreeNode"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "com.cacao.operation.security.model.PlatformMenuTreeNode": {
                "properties": {
                    "children": {
                        "type": "array",
                        "description": "子节点",
                        "items": {
                            "$ref": "#/components/schemas/com.cacao.operation.security.model.PlatformMenuTreeNode"
                        }
                    },
                    "resources": {
                        "type": "array",
                        "description": "菜单下挂的资源",
                        "items": {
                            "$ref": "#/components/schemas/com.cacao.operation.security.model.PlatformMenuTreeResourceNode"
                        }
                    }
                }
            },
            "com.cacao.operation.security.model.PlatformMenuTreeResourceNode": {
                "description": "菜单下挂的资源",
                "properties": {
                    "id": {
                        "type": "integer",
                        "format": "int64",
                        "description": "ID"
                    }
                }
            }
        }
    }
}
  1. Click menu '/security/role-config/menu-tree'

Expected behavior

show the request and response

Screenshots

eg

Additional context or thoughts

@char0n char0n changed the title RangeError: Maximum call stack size exceeded OpenAPI 3.1.0 support: RangeError: Maximum call stack size exceeded Apr 1, 2023
@char0n char0n self-assigned this Apr 1, 2023
@char0n
Copy link
Member

char0n commented Apr 3, 2023

This is an issue with ApiDOM, which is used by swagger-client that facilitates OpenAPI 3.1.0 dereference for the SwaggerUI.

It seems that all the cycles haven't been eliminated in swagger-client which resulted in error in transducer. Transducer can only handle acyclic directed graphs.

@char0n
Copy link
Member

char0n commented Apr 3, 2023

Minimal reproducible fixture is this one:

{
  "openapi": "3.1.0",
  "components": {
    "schemas": {
      "PlatformMenuTreeNode": {
        "properties": {
          "children": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlatformMenuTreeNode"
            }
          },
          "resources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlatformMenuTreeResourceNode"
            }
          }
        }
      },
      "PlatformMenuTreeResourceNode": {
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "ID"
          }
        }
      }
    }
  }
}

char0n added a commit to swagger-api/apidom that referenced this issue Apr 3, 2023
@char0n
Copy link
Member

char0n commented Apr 3, 2023

@char0n
Copy link
Member

char0n commented Apr 3, 2023

@char0n
Copy link
Member

char0n commented Apr 4, 2023

Tested with upstream fixes in SwaggerUI@5 using swagger-client@3.19.6:

image

char0n added a commit that referenced this issue Apr 4, 2023
The fix comes from updating the swagger-client
to v3.19.6.

Refs #8537
char0n added a commit that referenced this issue Apr 4, 2023
…8547)

The fix comes from updating the swagger-client to v3.19.6.

Refs #8537
@char0n
Copy link
Member

char0n commented Apr 4, 2023

Fixed in SwaggerUI - https://github.com/swagger-api/swagger-ui/releases/tag/v5.0.0-alpha.6. The SwaggerEditor@5 integration will follow during today.

@char0n char0n closed this as completed Apr 4, 2023
@char0n
Copy link
Member

char0n commented May 22, 2023

Reopening as I can still reproduce the issue by expadning Com.cacao.operation.security.model.PlatformMenuTreeNode in bottom section of the SwaggerUI:

image

@char0n char0n reopened this May 22, 2023
@char0n
Copy link
Member

char0n commented May 22, 2023

The issue was re-introduced by #8616.

Before the change we resolved the entire components.schemas section. Now we're just resolving individual Schema Objects in components.schemas when individual Schema Object is expanded.

@char0n
Copy link
Member

char0n commented May 23, 2023

Addressed in swagger-api/swagger-js#2970

@char0n
Copy link
Member

char0n commented May 24, 2023

Verified locally that the bug is gone after using swagger-client@3.19.8 (with swagger-api/swagger-js#2970 included).

@char0n char0n closed this as completed May 24, 2023
@char0n char0n reopened this May 24, 2023
@char0n
Copy link
Member

char0n commented May 24, 2023

Will be available in next SwaggerUI@5 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants