swagger-api / swagger-api/swagger-codegen

[nodejs-server] cannot set serverPort

Open
#11,112 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

I would like to set serverPort with --additional-properties.
but this arguement is ignored to specify nodejs server mode.

Swagger-codegen version

3.0.26

Swagger declaration file content or url
Command line used for generation

node.js

$ swagger-codegen generate --additional-properties serverPort=8081 -i ./sample.yml -l nodejs-server -o ./tmp
$ cat tmp/index.js
'use strict';

var path = require('path');
var http = require('http');

var oas3Tools = require('oas3-tools');
var serverPort = 8080;

...

[FYI] python-flask

$ swagger-codegen generate --additional-properties serverPort=8081 -i ./sample.yml -l python-flask -o ./tmp

$ cat tmp/Dockerfile
FROM python:3.6-alpine

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY requirements.txt /usr/src/app/

RUN pip3 install --no-cache-dir -r requirements.txt

COPY . /usr/src/app

EXPOSE 8081
...
Steps to reproduce
$ swagger-codegen generate --additional-properties serverPort=8081 -i ./sample.yml -l nodejs-server -o ./tmp
Related issues/PRs
Suggest a fix/enhancement

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 nodejs-server generation command with serverPort=8081 and inspect the generated tmp/index.js, which currently shows 8080. Compare this with the python-flask example and trace how --additional-properties is handled for the nodejs-server generator. Done means the generated server uses the requested port, with a regression test if the generator's test location is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.