Skip to content

Commit eeeeea8

Browse files
authored
fix(generator): handle custom request escaping (#313)
1 parent b607c5f commit eeeeea8

File tree

8 files changed

+31
-36
lines changed

8 files changed

+31
-36
lines changed

.github/.cache_version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7
1+
7.0.2

.github/actions/cache/action.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ runs:
367367
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
368368
uses: actions/cache@v2
369369
with:
370-
path: clients/algoliasearch-client-php
370+
path: clients/algoliasearch-client-php/lib/Api/SearchApi.php
371371
key: |
372372
${{ env.CACHE_VERSION }}-${{
373373
hashFiles(
@@ -382,7 +382,7 @@ runs:
382382
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
383383
uses: actions/cache@v2
384384
with:
385-
path: clients/algoliasearch-client-php
385+
path: clients/algoliasearch-client-php/lib/Api/RecommendApi.php
386386
key: |
387387
${{ env.CACHE_VERSION }}-${{
388388
hashFiles(
@@ -397,7 +397,7 @@ runs:
397397
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
398398
uses: actions/cache@v2
399399
with:
400-
path: clients/algoliasearch-client-php
400+
path: clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php
401401
key: |
402402
${{ env.CACHE_VERSION }}-${{
403403
hashFiles(
@@ -412,7 +412,7 @@ runs:
412412
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
413413
uses: actions/cache@v2
414414
with:
415-
path: clients/algoliasearch-client-php
415+
path: clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php
416416
key: |
417417
${{ env.CACHE_VERSION }}-${{
418418
hashFiles(
@@ -427,7 +427,7 @@ runs:
427427
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
428428
uses: actions/cache@v2
429429
with:
430-
path: clients/algoliasearch-client-php
430+
path: clients/algoliasearch-client-php/lib/Api/InsightsApi.php
431431
key: |
432432
${{ env.CACHE_VERSION }}-${{
433433
hashFiles(
@@ -442,12 +442,12 @@ runs:
442442
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
443443
uses: actions/cache@v2
444444
with:
445-
path: clients/algoliasearch-client-php
445+
path: clients/algoliasearch-client-php/lib/Api/AbtestingApi.php
446446
key: |
447447
${{ env.CACHE_VERSION }}-${{
448448
hashFiles(
449-
'clients/algoliasearch-client-php/lib/Api/AbTestingApi.php',
450-
'clients/algoliasearch-client-php/lib/Configuration/AbTestingConfig.php',
449+
'clients/algoliasearch-client-php/lib/Api/AbtestingApi.php',
450+
'clients/algoliasearch-client-php/lib/Configuration/AbtestingConfig.php',
451451
'specs/bundled/abtesting.yml',
452452
'templates/php/**',
453453
'generators/src/**'
@@ -457,7 +457,7 @@ runs:
457457
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
458458
uses: actions/cache@v2
459459
with:
460-
path: clients/algoliasearch-client-php
460+
path: clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php
461461
key: |
462462
${{ env.CACHE_VERSION }}-${{
463463
hashFiles(

.github/workflows/check.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ jobs:
263263
if: steps.cache.outputs.cache-hit != 'true'
264264
run: yarn cli build clients java ${{ matrix.client.name }}
265265

266+
- name: Show diff for '${{ matrix.client.name }}' client
267+
if: steps.cache.outputs.cache-hit != 'true'
268+
run: git --no-pager diff
269+
266270
client_php:
267271
runs-on: ubuntu-20.04
268272
timeout-minutes: 10
@@ -289,7 +293,7 @@ jobs:
289293
id: cache
290294
uses: actions/cache@v2
291295
with:
292-
path: ${{ matrix.client.folder }}
296+
path: ${{ format('{0}/lib/Api/{1}.php', matrix.client.folder, matrix.client.api) }}
293297
key: |
294298
${{ env.CACHE_VERSION }}-${{
295299
hashFiles(
@@ -308,6 +312,10 @@ jobs:
308312
if: steps.cache.outputs.cache-hit != 'true'
309313
run: yarn cli build clients php ${{ matrix.client.name }}
310314

315+
- name: Show diff for '${{ matrix.client.name }}' client
316+
if: steps.cache.outputs.cache-hit != 'true'
317+
run: git --no-pager diff
318+
311319
client_javascript_tests:
312320
runs-on: ubuntu-20.04
313321
timeout-minutes: 10

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
}

openapitools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@
366366
"invokerPackage": "Algolia\\AlgoliaSearch",
367367
"globalProperty": "apis,supportingFiles",
368368
"additionalProperties": {
369-
"configClassname": "AbTestingConfig",
369+
"configClassname": "AbtestingConfig",
370370
"hasRegionalHost": true,
371371
"allowedRegions": "us-de",
372372
"variableNamingConvention": "camelCase",

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)