swagger-api / swagger-api/swagger-codegen

[nodejs-server] Bug NODE_ENV=production doesn’t disable stub

Open
#5,867 0 comments 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

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.