swagger-api / swagger-api/swagger-codegen
[nodejs-server] Bug NODE_ENV=production doesn’t disable stub
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
After setting NODE_ENV=production and DEBUG: swagger-tools:middleware:*. I can see
nodejs_1 | Sun, 18 Jun 2017 11:36:32 GMT swagger-tools:middleware:router Mock mode: disabled
But the stub data is still there. And I run a grep on the generated code, it seems there’s no handling for options.useStubs. And in the Service js file it simply just return he example without checking the useStubs variable.
Swagger-codegen version
2.2.2
Suggest a Fix
I reckon when generating the example code, it should also add the handling for the useStubs variable in order to enable and disable example data.
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 by locating the generated Node.js Service js file and the template that emits it, then trace how options.useStubs and NODE_ENV reach the example response. Done means generated production-mode services no longer return stub data when stubs are disabled, while stub mode still returns the example response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100