Skip to content

Error when using react-scripts with swagger-ui. #4509

Open
@pjaleeuwen

Description

@pjaleeuwen

When running react-scripts start SwaggerUI displays and imports fine. When running react-scripts build the transpiled js fails with 'Error: Expected the reducer to be a function.'

I'm using swagger-ui 3.14.0 together with: react-scripts 0.7.0, react: ^15.6.2, react-dom ^15.6.2.

package.json:

{
  "name": "dev-portal",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-scripts": "0.7.0"
  },
  "dependencies": {
    "flux": "^3.1.3",
    "highlight.js": "^9.12.0",
    "jquery": "3.1.1",
    "react": "^15.6.2",
    "react-copy-to-clipboard": "^5.0.1",
    "react-dom": "15.6.2",
    "react-highlight": "^0.10.0",
    "react-router-dom": "4.1.1",
    "swagger-ui": "3.14.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom"
  }
}

Usage of SwaggerUI:

import SwaggerUI from 'swagger-ui'

...
var ui = SwaggerUI({
                  dom_id: '#swagger-ui-container',
                  url: 'http://petstore.swagger.io/v2/swagger.json',
                  spec: api.swagger
              })

              if(this.state.apiKey != '') {
                ui.authActions.authorize({
                    api_key: {
                        name: "api_key",
                        schema: {type: "apiKey", in: "header", name: "x-api-key", description: ""},
                        value: this.state.apiKey}});
              }
...

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