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
  • #3781
Closed
Open
Issue created Aug 28, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][typescript-node] invalid handling of array param in forms, `encoding` options ignored

Created by: quezak

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

When using an array POST form parameter, the generated client serializes it improperly, and ignores the encoding settings in the request body specification.

  • parameter: scope, an array of strings
  • sample call: api.test(['scope1', 'scope2'])
  • expected request body with encoding.scope.explode: true: scope=scope1&scope=scope2
  • expected request body with encoding.scope.explode: false: scope=scope1,scope2
  • actual request body: scope%5B0%5D=scope1&scope%5B1%5D=scope2, which is the urlencoded form of scope[0]=scope1&scope[1]=scope2...
openapi-generator version
  • openapi-generator-cli-5.0.0-20190811.165202-11.jar
  • openapi-generator-cli-4.1.1.jar
OpenAPI declaration file content or url
openapi: 3.0.2

info:
  version: 0.0.1
  title: test

servers:
  - url: http://test

paths:
  /test:
    post:
      summary: test
      operationId: test
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required: [scope]
              properties:
                scope:
                  type: array
                  items:
                    type: string
                    enum: [scope1, scope2, scope3]
            encoding:
              scope:
                # btw: what is `contentType` intended to do here for a string param?
                # cli complains if it's not present, but the value seems to be ignored anyway...
                contentType: application/x-www-form-urlencoded
                style: form
                explode: false
      responses:
        '204':
          description: success
Command line used for generation

java -jar $GENERATOR_JAR generate -i test.yml -g typescript-node -p supportsES6=true -o .

Steps to reproduce
  1. Generate the client.
  2. Make the test call to any server, log the error and check the request body.
Assignee
Assign to
Time tracking