Swagger-ui: 3.25.1 - 3.25.3 swagger-ui-react docExpansion=list throws a TypeError

Created on 1 May 2020  Â·  14Comments  Â·  Source: swagger-api/swagger-ui

Using "swagger-ui-react": "3.25.1"

If I specify docExpansion=list,

 <SwaggerUI docExpansion="list" url={specUrl}  />

It will throw the following error

Uncaught TypeError: Cannot read property 'indexOf' of undefined
    at value (swagger-ui.js:8)
    at swagger-ui.js:1

Without docExpansion, it works

 <SwaggerUI url={specUrl}  />

With "swagger-ui-react": "3.25.0", docExpansion works

 <SwaggerUI docExpansion="list" url={specUrl}  />

Most helpful comment

In the meanwhile, I have just added the supportedSubmitMethods property (e.g. set to supportedSubmitMethods={["get", "put", "post", "delete"]}) and it works (version 3.25.4).

All 14 comments

downgrading worked for me as well.

~I'm also having this issue, but downgrading does not work for me (In fact I got this error on 3.25.0).~ I fixed by downgrading and it worked. I'm on the stable version of nodejs and npm. This just starting happening very recently too. My error is a little different:

TypeError: undefined is not an object (evaluating 's.indexOf')
    value — 1.chunk.js:232387
    configureFinalMapState — 1.chunk.js:217466
    updateStatePropsIfNeeded — 1.chunk.js:217515
    render — 1.chunk.js:217659
    ...

and also

The above error occurred in the <Connect(r)> component:
    in Connect(r) (created by t)
    in div (created by Lt)
    in Lt (created by t)
    in t (created by t)
    in div (created by t)
    ...

I'm also getting the same error when I have docExpansion="list". No error when I remove this prop. Downgrading to 3.25.0 also fixes the problem.

Uncaught (in promise) TypeError: Cannot read property 'indexOf' of undefined
    at value (swagger-ui.js:8)
    at swagger-ui.js:1
    at i.configureFinalMapState (connect.js:155)
    at i.computeStateProps (connect.js:142)
    at i.updateStatePropsIfNeeded (connect.js:204)
    at i.render (connect.js:340)
    at La (react-dom.production.min.js:182)
    at Fa (react-dom.production.min.js:181)
    at vs (react-dom.production.min.js:263)
    at cu (react-dom.production.min.js:246)

+1

We have same issue as well.

This is still an issue with swagger-ui-react 3.25.2.
In fact, swagger-ui is totally unusable. Regardless of the value of docExpansion, the component crashes hard when I attempt to expand anything. If I set it to full, it crashes before it even loads. If I don't set docExpansion at all, the component still crashes when I attempt to expand anything.

Solution for now is to revert to 3.25.0.

+1
using 3.25.0 works perfectly!

still broken in 3.25.3.

I know this is open-source effort, but a breaking bug that makes the library unusable in react unfixed for close to 3 weeks?

@edward-s yes, you'd expect that within 3 weeks someone would contribute and fix it...

Still broken in 3.25.4.

There's no need to keep repeating that the issue is not resolved with every release. When it's resolved, this ticket will be closed.

Found the problem. The latest change to swagger-ui-react added support for the supportedSubmitMethods prop. But if you don't set this value, then it gets passed to swagger-ui as null, which obviously doesn't have an indexOf property. I'm working on a fix and will have a PR for this shortly.

In the meanwhile, I have just added the supportedSubmitMethods property (e.g. set to supportedSubmitMethods={["get", "put", "post", "delete"]}) and it works (version 3.25.4).

As of the latest release, docExpansion is now working properly for me with list, full, none

Was this page helpful?
0 / 5 - 0 ratings

Related issues

liuya05 picture liuya05  Â·  3Comments

insideshell picture insideshell  Â·  3Comments

MartinMuzatko picture MartinMuzatko  Â·  4Comments

DavidBiesack picture DavidBiesack  Â·  4Comments

fehguy picture fehguy  Â·  3Comments