swagger-api / swagger-api/swagger-codegen

[Javascript] Suppress warnings

Open
#7,848 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I created a React app with create-react-app. I used swagger-codegen to create Javascript client. I see these warnings every time I run my app.

Compiled with warnings.

./src/api/src/model/FacetsResponse.js
Line 16: 'Facet' is defined but never used no-unused-vars

./src/api/src/model/FacetValue.js
Line 34: Useless constructor no-useless-constructor

./src/api/src/model/Facet.js
Line 35: Useless constructor no-useless-constructor

./src/api/src/ApiClient.js
Line 96: Expected '===' and instead saw '==' eqeqeq
Line 211: Expected '!==' and instead saw '!=' eqeqeq
Line 343: Expected '===' and instead saw '==' eqeqeq
Line 414: Expected '!==' and instead saw '!=' eqeqeq
Line 423: Expected '===' and instead saw '==' eqeqeq
Line 544: 'k' is already defined no-redeclare

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

Swagger-codegen version

I reproduced with both 2.3.1 jar and building my own jar from master.

Swagger declaration file content or url

https://github.com/melissachang/data-explorer/blob/ui-swagger-model/api/api.yaml

Command line used for generation

java -jar ~/swagger-codegen-cli.jar generate -i api/api.yaml -l javascript -o ui/src/api -DuseES6=true

Steps to reproduce

git clone -b ui-swagger-model https://github.com/melissachang/data-explorer.git
cd data-explorer
docker-compose up --build
Open new tab in browser. Open Developer console. Load localhost:4400.

See warnings in 2 places.

  1. docker-compose output
  2. Developer console
Related issues/PRs

Couldn't find anything

Suggest a fix/enhancement

Easiest fix is probably to "// eslint-disable-next-line", as suggested by warning.

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

Reproduce the warnings with the documented swagger-codegen command and the linked data-explorer branch. Inspect the generated model files FacetsResponse.js, FacetValue.js, Facet.js, and ApiClient.js, then trace how they are produced. Done means the generated React client no longer emits the listed ESLint warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.