Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5190
Closed
Open
Issue created Feb 02, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] Default nodejs-express-server generation not runnable in default express: error: undefined {"service":"user-service"}

Created by: d3vopz-net

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

Assignee
Assign to
Time tracking