[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 ofscope[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
- Generate the client.
- Make the test call to any server, log the error and check the request body.