Skip to content

Commit a1396b9

Browse files
committed
feat(generator): handle custom request escaping
1 parent 59ce8b4 commit a1396b9

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

clients/algoliasearch-client-javascript/bundlesize.config.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@
3535
{
3636
"path": "packages/recommend/dist/recommend.umd.browser.js",
3737
"maxSize": "3.80KB"
38-
},
39-
{
40-
"path": "packages/client-common/dist/client-common.esm.node.js",
41-
"maxSize": "5.25KB"
42-
},
43-
{
44-
"path": "packages/requester-browser-xhr/dist/requester-browser-xhr.esm.node.js",
45-
"maxSize": "900B"
46-
},
47-
{
48-
"path": "packages/requester-node-http/dist/requester-node-http.esm.node.js",
49-
"maxSize": "1.15KB"
5038
}
5139
]
5240
}

templates/java/libraries/okhttp-gson/api.mustache

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ public class {{classname}} extends ApiClient {
111111
Object bodyObj = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
112112

113113
// create path and map variables
114-
String requestPath = "{{{path}}}"{{#pathParams}}
115-
.replaceAll("\\{" + "{{baseName}}" + "\\}", this.escapeString({{{paramName}}}.toString())){{/pathParams}};
114+
String requestPath = "{{{path}}}"{{#vendorExtensions}}{{#pathParams}}.replaceAll(
115+
{{=<% %>=}}"\\{<%baseName%>\\}"<%={{ }}=%>,
116+
{{#x-is-custom-request}}{{{paramName}}}.toString(){{/x-is-custom-request}}{{^x-is-custom-request}}this.escapeString({{{paramName}}}.toString()){{/x-is-custom-request}}
117+
){{/pathParams}}{{/vendorExtensions}};
116118

117119
{{javaUtilPrefix}}List<Pair> queryParams = new {{javaUtilPrefix}}ArrayList<Pair>();
118120
{{javaUtilPrefix}}Map<String, String> headers = new {{javaUtilPrefix}}HashMap<String, String>();

templates/javascript/api-single.mustache

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,9 @@ export function create{{capitalizedApiName}}Api(options: CreateClientOptions{{#h
202202
{{/allParams.0}}
203203
requestOptions?: RequestOptions
204204
) : Promise<{{{returnType}}}> {
205-
const requestPath = '{{{path}}}'{{#pathParams}}.replace(
206-
{{=<% %>=}}
207-
'{<%baseName%>}',
208-
<%={{ }}=%>
209-
encodeURIComponent(String({{paramName}}))
210-
){{/pathParams}};
205+
const requestPath = '{{{path}}}'{{#vendorExtensions}}{{#pathParams}}.replace(
206+
{{=<% %>=}}'{<%baseName%>}'<%={{ }}=%>,{{#x-is-custom-request}}String({{paramName}}){{/x-is-custom-request}}{{^x-is-custom-request}}encodeURIComponent(String({{paramName}})){{/x-is-custom-request}}
207+
){{/pathParams}}{{/vendorExtensions}};
211208
const headers: Headers = {};
212209
const queryParameters: QueryParameters = {};
213210

templates/php/api.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
231231
}
232232
{{/isExplode}}
233233
{{/queryParams}}
234-
{{#pathParams}}
234+
{{#vendorExtensions}}{{#pathParams}}
235235
// path params
236236
{{#collectionFormat}}
237237
if (is_array(${{paramName}})) {
@@ -240,12 +240,12 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
240240
{{/collectionFormat}}
241241
if (${{paramName}} !== null) {
242242
$resourcePath = str_replace(
243-
'{' . '{{baseName}}' . '}',
244-
ObjectSerializer::toPathValue(${{paramName}}),
243+
{{=<% %>=}}'{<%baseName%>}'<%={{ }}=%>,
244+
{{#x-is-custom-request}}{{paramName}}{{/x-is-custom-request}}{{^x-is-custom-request}}ObjectSerializer::toPathValue(${{paramName}}){{/x-is-custom-request}},
245245
$resourcePath
246246
);
247247
}
248-
{{/pathParams}}
248+
{{/pathParams}}{{/vendorExtensions}}
249249

250250
{{#bodyParams}}
251251
if (isset(${{paramName}})) {

0 commit comments

Comments
 (0)