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
  • #8140
Closed
Open
Issue created Dec 09, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [nodejs-express-server] Function with object as parameter

Created by: koldou98

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When I create the server with nodejs express server, in the tagNameServices creates the services properly, but when the requested parameter is an object it generates it in the following way:

const foo = ({ foo }) => new Promise(
  async (resolve, reject) => {
    try {
      resolve(Service.successResponse({
        foo,
      }));
    } catch (e) {
      reject(Service.rejectResponse(
        e.message || 'Invalid input',
        e.status || 405,
      ));
    }
  },
);

The problem is that {tag} is that the parameter is always null. I would like the generator to create a variable without the object brackets.

openapi-generator version

4.3.1

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Issue
  version: 1.0.0
servers:
  - url: http://localhost:4000/
tags:
  - name: tag

paths:
  /tag:
    post:
      operationId: foo
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/foo'
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responsefoo'
          description: foo
      tags:
        - tag
components:
  schemas:
    foo:
      additionalProperties: false
      properties:
        test:
          description: |
            test
          maxLength: 12
          pattern: \s*
          type: string
      type: object
    responsefoo:
      additionalProperties: false
      example:
        msg: Se ha encendido el smartplug
      properties:
        msg:
          description: ok
          maxLength: 2
          minLength: 2
          pattern: '[\s]+'
          type: string
      readOnly: true
      type: object
Generation Details
openapi-generator-cli generate -i {path}/name.yaml -g nodejs-express-server -o {path}
Steps to reproduce

Open a terminal/cmd... and execute the following commnad

openapi-generator-cli generate -i {path}/name.yaml -g nodejs-express-server -o {path}

In Services/TagServices u will find the object as function parameter

Suggest a fix

Do not generate the parameter as an object

Assignee
Assign to
Time tracking