Skip to content

Commit

Permalink
fixes OpenAPITools#18489: provide support of array attributes in mult…
Browse files Browse the repository at this point in the history
…ipart/form-data request for angular typescript client
  • Loading branch information
jeandonaldroselin committed May 28, 2024
1 parent efb7e56 commit f07eb43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public static enum PROVIDED_IN_LEVEL {none, root, any, platform}
public static final String STRING_ENUMS = "stringEnums";
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
public static final String QUERY_PARAM_OBJECT_FORMAT = "queryParamObjectFormat";
public static final String USE_SQUARE_BRACKETS_IN_ARRAY_NAMES = "useSquareBracketsInArrayNames";

protected String ngVersion = "17.0.0";
protected String npmRepository = null;
Expand Down Expand Up @@ -138,6 +139,7 @@ public TypeScriptAngularClientCodegen() {
this.cliOptions.add(new CliOption(FILE_NAMING, "Naming convention for the output files: 'camelCase', 'kebab-case'.").defaultValue(this.fileNaming));
this.cliOptions.add(new CliOption(STRING_ENUMS, STRING_ENUMS_DESC).defaultValue(String.valueOf(this.stringEnums)));
this.cliOptions.add(new CliOption(QUERY_PARAM_OBJECT_FORMAT, "The format for query param objects: 'dot', 'json', 'key'.").defaultValue(this.queryParamObjectFormat.name()));
this.cliOptions.add(CliOption.newBoolean(USE_SQUARE_BRACKETS_IN_ARRAY_NAMES, "Setting this property to true will add brackets to array attribute names.", false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,16 @@ export class {{classname}} {
if ({{paramName}}) {
{{#isCollectionFormatMulti}}
{{paramName}}.forEach((element) => {
localVarFormParams = localVarFormParams.append('{{baseName}}', <any>element) as any || localVarFormParams;
localVarFormParams = localVarFormParams.append('{{baseName}}{{#useSquareBracketsInArrayNames}}[]{{/useSquareBracketsInArrayNames}}', <any>element) as any || localVarFormParams;
})
{{/isCollectionFormatMulti}}
{{^isCollectionFormatMulti}}
if (localVarUseForm) {
{{paramName}}.forEach((element) => {
localVarFormParams = localVarFormParams.append('{{baseName}}', <any>element) as any || localVarFormParams;
localVarFormParams = localVarFormParams.append('{{baseName}}{{#useSquareBracketsInArrayNames}}[]{{/useSquareBracketsInArrayNames}}', <any>element) as any || localVarFormParams;
})
} else {
localVarFormParams = localVarFormParams.append('{{baseName}}', [...{{paramName}}].join(COLLECTION_FORMATS['{{collectionFormat}}'])) as any || localVarFormParams;
localVarFormParams = localVarFormParams.append('{{baseName}}{{#useSquareBracketsInArrayNames}}[]{{/useSquareBracketsInArrayNames}}', [...{{paramName}}].join(COLLECTION_FORMATS['{{collectionFormat}}'])) as any || localVarFormParams;
}
{{/isCollectionFormatMulti}}
}
Expand Down

0 comments on commit f07eb43

Please sign in to comment.