OpenAPITools / OpenAPITools/openapi-generator
[BUG] Default nodejs-express-server generation not runnable in default express: error: undefined {"service":"user-service"}
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
cannot run the default stub of nodejs-express-server.
it creates a logger.js with winston and a user-service, which is not handled in the stub.
the output of npm is
error: undefined {"service":"user-service"}
error: undefined {"service":"user-service"}
caused by created logger.js
const winston = require('winston');
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
defaultMeta: { service: 'user-service' },
transports: [
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' }),
],
});
if (process.env.NODE_ENV !== 'production') {
logger.add(new winston.transports.Console({ format: winston.format.simple() }));
}
module.exports = logger;
openapi-generator version
openapitools/openapi-generator-cli:v4.2.3
OpenAPI declaration file content or url
openapi: '3.0.2'
info:
title: Tree
description: "d3vopz open api spec for tree operations"
termsOfService: /terms-of-use
version: '0.0.0'
contact:
name: "Tree API"
url: "https://d3vopz.net/api"
email: "d3vopz.net@gmail.com"
license:
name: "Don't use ;)"
url: "https://d3vopz.net/license"
externalDocs: # Relative URL to external documentation
url: /docs
description: Find more info here
servers:
# - url: '{protocol}://{environment}.{host}/v{versionId}{versionStage}{versionStageId}'
- url: '{protocol}://{environment}.{host}/v{versionId}{versionStage}{versionStageId}'
variables:
protocol:
enum:
- http
- https
default: https
environment:
default: api # Production server
enum:
- api # Production server
- api.dev # Development server
- api.staging # Staging server
host:
default: localhost # local server
# versionId:
# default: "1" # 1st
# versionStage:
# default: "" # stable
# enum:
# - "" # stable stage
# - "alpha" # alpha stage
# - "beta" # beta stage
# versionStageId:
# default: "" # stable (empty)
paths:
/tree:
get:
tags:
- Current tree data
summary: "Call current node data."
description: "Cet current node data."
operationId: CurrentNodeData
parameters:
- name: idx
in: query
description: "nodes idx"
schema:
type: integer
format: int64
responses:
200:
description: Successful response
content:
application/json:
schema:
title: Sample
type: object
properties:
placeholder:
type: string
description: Placeholder description
404:
description: Not found response
content:
text/plain:
schema:
title: Node not found
type: string
example: Not found
Command line used for generation
create the stub with:
openapitools/openapi-generator-cli:v4.2.3 generate -i /local/openapi.yml -g nodejs-express-server -o /local/out/nodejs-express-server
running the stub in
npm --prefix /data start
where /data contains the stub
Steps to reproduce
see command line
Related issues/PRs
Did not find a similiar issue
Suggest a fix
providing an example how to get it simple running with winston or disable complex winston log as default? idk
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 the generated logger.js and the nodejs-express-server output produced by the command in the issue. Reproduce it with OpenAPI Generator v4.2.3 and npm --prefix /data start, then determine whether the default Winston setup or the generated stub causes the error. Done means the default generated server starts without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- express, javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100