Skip to content

Swagger UI path variables are broken on react 16+ #5165

@iKrushYou

Description

@iKrushYou

I'm running into an issue with swagger path parameters when serving through react versions greater than 16 (i'm not 100% sure exactly when it stopped working, but i have tested between versions 15.4.1 => 16.4.1 and I can get it working on the former.

I am using the very basic of set ups for my control test -- the petstore.json example (contained inside of the const spec)

and here is my App.js

class App extends Component {
  componentDidMount() {
      SwaggerUi({
          dom_id: "#swagger-ui",
          spec: spec,
          presets: [presets.apis]
      })
  }

  render() {
    return (
      <div className="App">
        <h1>Swagger Test</h1>
          <div>React version: {REACT_VERSION}</div>
            <div>Swagger version: {SWAGGER_VERSION}</div>
        <div id={"swagger-ui"} />
      </div>
    );
  }
}

When trying to make a call through the UI which requires a path variable, the UI acts as if the field wasn't filled in:
image
However, that same API test works in React version 15.4.1. I am not sure what would be causing it and why it's related to the React versions.. but it is quite frustrating.

Any suggestions or workarounds?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions