-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Description
Description
generator for typescript-axios and other typescript-* generators
incorrectly generates pipe when the collection format is pipes.
openapi-generator version
4.2.3-SNAPSHOT
OpenAPI declaration file content or url
pipes.yaml:
swagger: '2.0'
info:
title: pipes
version: '0.0.0'
basePath: /test
paths:
/data:
get:
parameters:
- name: typeQueryParam
in: query
description: >-
Subset the items to those matching one or more types (pipe-separated).
type: array
collectionFormat: pipes
items:
type: string
enum:
- a
- b
- c
- d
responses:
'200':
description: OKCommand line used for generation
openapi-generator generate -g typescript-axios -i pipes.yaml -o __sdk
Steps to reproduce
run the above command.
The generated __sdk/api.ts contains
localVarQueryParameter['typeQueryParam'] = typeQueryParam.join(COLLECTION_FORMATS.pipe);
but pipe should be pipes:
localVarQueryParameter['typeQueryParam'] = typeQueryParam.join(COLLECTION_FORMATS.pipes);
The Mustache template ./modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache line looks correct
localVarFormParams.set('{{baseName}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));{{/multipartFormData}}{{#multipartFormData}}
so perhaps openapi-codegen is converting the pipes in the source to the template variable {{collectionFormat}} with value pipe instead.
Related issues/PRs
Suggest a fix
modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
} else if (Parameter.StyleEnum.PIPEDELIMITED.equals(parameter.getStyle())) {
return "pipe";
should be
protected String getCollectionFormat(Parameter parameter) {
...
} else if (Parameter.StyleEnum.PIPEDELIMITED.equals(parameter.getStyle())) {
return "pipes";
The line below looks incorrect as well:
} else if (Parameter.StyleEnum.SPACEDELIMITED.equals(parameter.getStyle())) {
return "space";
should be
} else if (Parameter.StyleEnum.SPACEDELIMITED.equals(parameter.getStyle())) {
return "ssv";
in order to match the generated definition
/**
*
- @export
*/
export const COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: "\t",
pipes: "|",
};
I can submit a PR
Reactions are currently unavailable