forked from loafle/openapi-generator-original
[typescript-fetch] Support deepObject query params (#6075)
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.
This commit is contained in:
parent
3d5b140c3d
commit
354f195ec0
@ -236,9 +236,23 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
|||||||
this.addOperationObjectResponseInformation(operations);
|
this.addOperationObjectResponseInformation(operations);
|
||||||
this.addOperationPrefixParameterInterfacesInformation(operations);
|
this.addOperationPrefixParameterInterfacesInformation(operations);
|
||||||
this.escapeOperationIds(operations);
|
this.escapeOperationIds(operations);
|
||||||
|
this.addDeepObjectVendorExtension(operations);
|
||||||
return 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) {
|
private void escapeOperationIds(Map<String, Object> operations) {
|
||||||
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
Map<String, Object> _operations = (Map<String, Object>) operations.get("operations");
|
||||||
List<CodegenOperation> operationList = (List<CodegenOperation>) _operations.get("operation");
|
List<CodegenOperation> operationList = (List<CodegenOperation>) _operations.get("operation");
|
||||||
|
@ -122,7 +122,12 @@ export class {{classname}} extends runtime.BaseAPI {
|
|||||||
queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString().substr(0,10);
|
queryParameters['{{baseName}}'] = (requestParameters.{{paramName}} as any).toISOString().substr(0,10);
|
||||||
{{/isDate}}
|
{{/isDate}}
|
||||||
{{^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}};
|
queryParameters['{{baseName}}'] = requestParameters.{{paramName}};
|
||||||
|
{{/vendorExtensions.x-codegen-isDeepObject}}
|
||||||
{{/isDate}}
|
{{/isDate}}
|
||||||
{{/isDateTime}}
|
{{/isDateTime}}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user