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

Maximum call stack size exceeded #994

Closed
MrFix93 opened this issue Jul 31, 2019 · 5 comments
Closed

Maximum call stack size exceeded #994

MrFix93 opened this issue Jul 31, 2019 · 5 comments

Comments

@MrFix93
Copy link
Contributor

MrFix93 commented Jul 31, 2019

The following swagger specification (which replicates the bug we've encountered) fails to render in the ReactStandalone component. It is valid swagger specification and swagger-ui renders this correctly. The critical lines to look for is:

Pet:
    title: "Pet"
    allOf:
      - $ref: "#/definitions/Pet"

This seems a bit strange, however, validating the spec with swagger editor does not produce any warnings or errors. Removing the line is not an option as the specification is generated from java code.

swagger: "2.0"
info:
  description: "This is a sample server Petstore server.  You can find out more about     Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).      For this sample, you can use the api key `special-key` to test the authorization     filters."
  version: "1.0.0"
  title: "Swagger Petstore"
  termsOfService: "http://swagger.io/terms/"
  contact:
    email: "apiteam@swagger.io"
  license:
    name: "Apache 2.0"
    url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
tags:
  - name: "pet"
    description: "Everything about your Pets"
    externalDocs:
      description: "Find out more"
      url: "http://swagger.io"
  - name: "store"
    description: "Access to Petstore orders"
  - name: "user"
    description: "Operations about user"
    externalDocs:
      description: "Find out more about our store"
      url: "http://swagger.io"
schemes:
  - "https"
  - "http"
paths:
  /pet:
    post:
      tags:
        - "pet"
      summary: "Add a new pet to the store"
      description: ""
      operationId: "addPet"
      consumes:
        - "application/json"
        - "application/xml"
      produces:
        - "application/xml"
        - "application/json"
      parameters:
        - in: "body"
          name: "body"
          description: "Pet object that needs to be added to the store"
          required: true
          schema:
            $ref: "#/definitions/Pet"
      responses:
        405:
          description: "Invalid input"
    put:
      tags:
        - "pet"
      summary: "Update an existing pet"
      description: ""
      operationId: "updatePet"
      consumes:
        - "application/json"
        - "application/xml"
      produces:
        - "application/xml"
        - "application/json"
      parameters:
        - in: "body"
          name: "body"
          description: "Pet object that needs to be added to the store"
          required: true
          schema:
            $ref: "#/definitions/Pet"
      responses:
        400:
          description: "Invalid ID supplied"
        404:
          description: "Pet not found"
        405:
          description: "Validation exception"
definitions:
  Pet:
    title: "Pet"
    allOf:
      - $ref: "#/definitions/Pet"
      - type: "object"
        required:
          - "name"
          - "photoUrls"
        properties:
          id:
            type: "integer"
            format: "int64"
          name:
            type: "string"
            example: "doggie"
          photoUrls:
            type: "array"
            xml:
              name: "photoUrl"
              wrapped: true
            items:
              type: "string"
          status:
            type: "string"
            description: "pet status in the store"
            enum:
              - "available"
              - "pending"
              - "sold"
    xml:
      name: "Pet"
externalDocs:
  description: "Find out more about Swagger"
  url: "http://swagger.io"

It generates the following errors:

redoc.lib.js:8587 Uncaught RangeError: Maximum call stack size exceeded
    at OpenAPIParser.mergeAllOf (redoc.lib.js:8587)
    at eval (redoc.lib.js:8598)
    at Array.map (<anonymous>)
    at OpenAPIParser.mergeAllOf (redoc.lib.js:8594)
    at eval (redoc.lib.js:8598)
    at Array.map (<anonymous>)
    at OpenAPIParser.mergeAllOf (redoc.lib.js:8594)
    at eval (redoc.lib.js:8598)
    at Array.map (<anonymous>)
    at OpenAPIParser.mergeAllOf (redoc.lib.js:8594)
OpenAPIParser.mergeAllOf @ redoc.lib.js:8587
(anonymous) @ redoc.lib.js:8598
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
[..... same error * 80 ]
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
OpenAPIParser.mergeAllOf @ redoc.lib.js:8594
(anonymous) @ redoc.lib.js:8598
Promise.then (async)
step @ tslib.es6.js:93
(anonymous) @ tslib.es6.js:94
__awaiter @ tslib.es6.js:90
StoreBuilder.load @ redoc.lib.js:10078
StoreBuilder.componentDidMount @ redoc.lib.js:10066
commitLifeCycles @ react-dom.development.js:17334
commitAllLifeCycles @ react-dom.development.js:18736
callCallback @ react-dom.development.js:149
invokeGuardedCallbackDev @ react-dom.development.js:199
invokeGuardedCallback @ react-dom.development.js:256
commitRoot @ react-dom.development.js:18948
(anonymous) @ react-dom.development.js:20418
unstable_runWithPriority @ scheduler.development.js:255
completeRoot @ react-dom.development.js:20417
performWorkOnRoot @ react-dom.development.js:20346
performWork @ react-dom.development.js:20254
performSyncWork @ react-dom.development.js:20228
interactiveUpdates$1 @ react-dom.development.js:20495
interactiveUpdates @ react-dom.development.js:2170
dispatchInteractiveEvent @ react-dom.development.js:4882
Show 170 more frames
2react-dom.development.js:17117 The above error occurred in the <Context.Consumer> component:
    in Operation (created by OperationItem)
    in OperationItem (created by ContentItem)
    in div (created by Context.Consumer)
    in StyledComponent (created by styled.div)
    in styled.div (created by ContentItem)
    in ContentItem (created by ContentItems)
    in ContentItems (created by ContentItem)
    in ContentItem (created by ContentItems)
    in ContentItems (created by Redoc)
    in div (created by Context.Consumer)
    in StyledComponent (created by styled.div)
    in styled.div (created by Redoc)
    in div (created by Context.Consumer)
    in StyledComponent (created by styled.div)
    in styled.div (created by Redoc)
    in ThemeProvider (created by Redoc)
    in Redoc (created by StoreBuilder)
    in StoreBuilder (created by RedocStandalone)
    in ErrorBoundary (created by RedocStandalone)
    in RedocStandalone (created by RenderSwagger)
    in RenderSwagger (created by Context.Consumer)
    in Route (created by ReferenceModule)
    in ReferenceModule (created by Context.Consumer)
    in Route (created by App)
    in Switch (created by App)
    in Router (created by BrowserRouter)
    in BrowserRouter (created by App)
    in App
@RomanHotsiy
Copy link
Member

Well, that definitely looks strange. I will look into this.

@RomanHotsiy
Copy link
Member

Well, I just thought about it and this self-referencing doesn't make any sense.

Removing the line is not an option as the specification is generated from java code.

How is it generated? I would suggest fixing the issue in the tool that generates this.

@MrFix93
Copy link
Contributor Author

MrFix93 commented Aug 7, 2019

Oh well. This seems to be related to this Issue. In my pull-request (which I'm gonna submit in just a minute), this is not an issue anymore. You are right, 'uri-template-lite' seems to cause a lot of troubles.
edit: Or, rc13 have fixed it, but haven't figured it out yet.

@MrFix93
Copy link
Contributor Author

MrFix93 commented Aug 7, 2019

Created pull-request #1008

@lornajane
Copy link
Contributor

We merged the pull request, but didn't close the issue, so I'll do that now!

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

No branches or pull requests

3 participants