swagger-api / swagger-api/swagger-ui

Error when using react-scripts with swagger-ui.

Open
#4,509 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: integration bug
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

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}});
              }
...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the difference between react-scripts start and react-scripts build using the versions in package.json, then inspect the transpiled build output around the reducer error. Review the SwaggerUI initialization shown in the issue and compare its behavior in development and production; done means the production build completes and Swagger UI loads without the reducer error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
build-system, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.