Skip to content

Commit

Permalink
feat(generator): handle custom request escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Mar 31, 2022
1 parent 59ce8b4 commit b81a580
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 18 deletions.
12 changes: 0 additions & 12 deletions clients/algoliasearch-client-javascript/bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@
{
"path": "packages/recommend/dist/recommend.umd.browser.js",
"maxSize": "3.80KB"
},
{
"path": "packages/client-common/dist/client-common.esm.node.js",
"maxSize": "5.25KB"
},
{
"path": "packages/requester-browser-xhr/dist/requester-browser-xhr.esm.node.js",
"maxSize": "900B"
},
{
"path": "packages/requester-node-http/dist/requester-node-http.esm.node.js",
"maxSize": "1.15KB"
}
]
}
2 changes: 1 addition & 1 deletion templates/java/libraries/okhttp-gson/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public class {{classname}} extends ApiClient {

// create path and map variables
String requestPath = "{{{path}}}"{{#pathParams}}
.replaceAll("\\{" + "{{baseName}}" + "\\}", this.escapeString({{{paramName}}}.toString())){{/pathParams}};
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{#vendorExtensions.x-is-custom-request}}{{{paramName}}}.toString()){{/vendorExtensions.x-is-custom-request}}{{^vendorExtensions.x-is-custom-request}}this.escapeString({{{paramName}}}.toString())){{/vendorExtensions.x-is-custom-request}}{{/pathParams}};

{{javaUtilPrefix}}List<Pair> queryParams = new {{javaUtilPrefix}}ArrayList<Pair>();
{{javaUtilPrefix}}Map<String, String> headers = new {{javaUtilPrefix}}HashMap<String, String>();
Expand Down
6 changes: 2 additions & 4 deletions templates/javascript/api-single.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,8 @@ export function create{{capitalizedApiName}}Api(options: CreateClientOptions{{#h
requestOptions?: RequestOptions
) : Promise<{{{returnType}}}> {
const requestPath = '{{{path}}}'{{#pathParams}}.replace(
{{=<% %>=}}
'{<%baseName%>}',
<%={{ }}=%>
encodeURIComponent(String({{paramName}}))
{{=<% %>=}}'{<%baseName%>}',<%={{ }}=%>
{{#vendorExtensions.x-is-custom-request}}String({{paramName}}){{/vendorExtensions.x-is-custom-request}}{{^vendorExtensions.x-is-custom-request}}encodeURIComponent(String({{paramName}})){{/vendorExtensions.x-is-custom-request}}
){{/pathParams}};
const headers: Headers = {};
const queryParameters: QueryParameters = {};
Expand Down
2 changes: 1 addition & 1 deletion templates/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
if (${{paramName}} !== null) {
$resourcePath = str_replace(
'{' . '{{baseName}}' . '}',
ObjectSerializer::toPathValue(${{paramName}}),
{{#vendorExtensions.x-is-custom-request}}{{paramName}}{{/vendorExtensions.x-is-custom-request}}{{^vendorExtensions.x-is-custom-request}}ObjectSerializer::toPathValue(${{paramName}}){{/vendorExtensions.x-is-custom-request}},
$resourcePath
);
}
Expand Down

0 comments on commit b81a580

Please sign in to comment.