Skip to content

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

Open
@koldou98

Description

@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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions