swagger-api / swagger-api/swagger-codegen
[Javascript] using browersify on javascript client
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I tried to follow the instruction present in the README.md file generated by the generator, in order to get a client that is usable in the browser
browserify index.js > bundle.js
but the command failed indicating
Error: Parsing file /home/.../petstore/javascript/src/index.js: 'import' and 'export' may appear only with 'sourceType: module' (16:0)
at Deps.parseDeps (/usr/lib/node_modules/browserify/node_modules/module-deps/index.js:519:15)
at getDeps (/usr/lib/node_modules/browserify/node_modules/module-deps/index.js:447:44)
at /usr/lib/node_modules/browserify/node_modules/module-deps/index.js:430:38
at ConcatStream.<anonymous> (/usr/lib/node_modules/browserify/node_modules/concat-stream/index.js:37:43)
at emitNone (events.js:111:20)
at ConcatStream.emit (events.js:208:7)
at finishMaybe (/usr/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:630:14)
at endWritable (/usr/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:638:3)
at ConcatStream.Writable.end (/usr/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:594:41)
at DuplexWrapper.onend (/usr/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:577:10)
Swagger-codegen version
The version is 3.0.27
java -jar swagger-codegen-cli.jar version
3.0.27
Swagger declaration file content or url
I'm using the petstore api
https://petstore.swagger.io/v2/swagger.json
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i swagger.json -l javascript -o javascript
Steps to reproduce
cd javascript/src
browserify index.js > bundle.js
Related issues/PRs
No
Suggest a fix/enhancement
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with javascript/src/index.js and the generated README, then reproduce the failure from javascript/src with browserify index.js > bundle.js. Trace the generated client entry point and its browser bundling instructions; done means the documented command completes without the import/export parsing error and produces bundle.js.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100