Skip to content

Commit

Permalink
[typescript-fetch] Support deepObject query params (OpenAPITools#6075)
Browse files Browse the repository at this point in the history
deepObject query parameters need to be specially marshalled.
Unfortunately, they're quite tricky to distinguish in mustache because
there's no boolean property for deepObject, so add a vendorExtension
property to ease the mustache template.
  • Loading branch information
haraldF authored and MikailBag committed May 31, 2020
1 parent 92b02ad commit e90c538
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,23 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
this.addOperationObjectResponseInformation(operations);
this.addOperationPrefixParameterInterfacesInformation(operations);
this.escapeOperationIds(operations);
this.addDeepObjectVendorExtension(operations);
return operations;
}

private void addDeepObjectVendorExtension(Map<String, Object> operations) {
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) _operations.get("operation");

for (CodegenOperation op : operationList) {
for (CodegenParameter param : op.queryParams) {
if (param.style != null && param.style.equals("deepObject")) {
param.vendorExtensions.put("x-codegen-isDeepObject", true);
}
}
}
}

private void escapeOperationIds(Map<String, Object> operations) {
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) _operations.get("operation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ export class {{classname}} extends runtime.BaseAPI {
queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString().substr(0,10);
{{/isDate}}
{{^isDate}}
{{#vendorExtensions.x-codegen-isDeepObject}}
queryParameters['{{baseName}}'] = runtime.querystring(requestParameters.{{paramName}} as unknown as runtime.HTTPQuery, '{{baseName}}');
{{/vendorExtensions.x-codegen-isDeepObject}}
{{^vendorExtensions.x-codegen-isDeepObject}}
queryParameters['{{baseName}}'] = requestParameters.{{paramName}};
{{/vendorExtensions.x-codegen-isDeepObject}}
{{/isDate}}
{{/isDateTime}}
}
Expand Down

0 comments on commit e90c538

Please sign in to comment.