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
  • #4679
Closed
Open
Issue created Dec 03, 2019 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG][NODEJS-EXPRESS-SERVER] Body data will not be processed.

Created by: cjuenger

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

The generated server stub does not handle data (defined as schema in OpenAPI 3.0) transferred in the body HTTP. The generated code uses the name of the schema (here: bodyData) as the name of the input parameter of the generated service method (here: static addDataPerBody({bodyData}).

That is the issue, the controller parses all data in the body of a HTTP request into 'requestParams.body' which won't work for destructuring the assignment to '{bodyData}'.

See 'Suggest a fix' below for a possible fix.

openapi-generator version

Version 4.2.2

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Titel
  description: Some description 
  version: 0.0.0.0
servers:
  - url: /some/uri
paths:
  
  /groups:
    post:
      operationId: addDataPerBody
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BodyData'
        required: true
      responses:
        '200':
          description: Id of added data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataId'
    
components:
  schemas:    
    BodyData:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        info:
          type: string
        created:
          type: string
        changed:
          type: string
      required:
        - name
    DataId:
      type: object
      properties:
        id:
          type: integer
          description: ID of the group.
Command line used for generation

openapi-generator generate -g nodejs-express-server -i .\FILE.yaml -o .\TARGET\DIR

Steps to reproduce
Related issues/PRs
Suggest a fix

Every service function parameter simply needs to be identified by 'body' and aliased by the schema name.

For example: Change 'static addDataPerBody({bodyData})' to 'static addDataPerBody({'body': bodyData})'

Assignee
Assign to
Time tracking