Skip to content

Commit 7d39b0b

Browse files
fix: web SDK removing global params
1 parent 2dfc5f7 commit 7d39b0b

File tree

5 files changed

+43
-64
lines changed

5 files changed

+43
-64
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
"ext-curl": "*",
2424
"ext-mbstring": "*",
2525
"ext-json": "*",
26-
"twig/twig": "^3.3",
27-
"matthiasmullie/minify": "^1.3"
26+
"twig/twig": "^3.4.1",
27+
"matthiasmullie/minify": "^1.3.68"
2828
},
2929
"require-dev": {
30-
"phpunit/phpunit": "^9.5.13",
30+
"phpunit/phpunit": "^9.5.21",
3131
"brianium/paratest": "^6.4"
3232
},
3333
"minimum-stability": "dev",

composer.lock

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specs/swagger2-latest-console.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

templates/web/src/models.ts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export namespace Models {
88
/**
99
* {{ property.description }}
1010
*/
11-
{{ property.name | escapeKeyword }}{% if not property.required %}?{% endif %}: {{ property | getSubSchema(spec) | raw }};
11+
{{ property.name }}{% if not property.required %}?{% endif %}: {{ property | getSubSchema(spec) | raw }};
1212
{% endfor %}
1313
{% if definition.additionalProperties %} [key: string]: any;
1414
{% endif %}

templates/web/src/services/template.ts.twig

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,13 @@
11
import { Service } from '../service';
22
import { {{ spec.title | caseUcfirst}}Exception, Client } from '../client';
33
import type { Models } from '../models';
4-
import type { UploadProgress } from '../client';
5-
6-
type Payload = {
7-
[key: string]: any;
8-
}
4+
import type { UploadProgress, Payload } from '../client';
95

106
export class {{ service.name | caseUcfirst }} extends Service {
11-
{% if service.globalParams | length %}
12-
{% for parameter in service.globalParams %}
13-
protected {{ parameter.name | caseCamel | escapeKeyword }}: {{ parameter.type | typeName }};
14-
public set{{ parameter.name | caseUcfirst | escapeKeyword }}({{ parameter.name | caseCamel | escapeKeyword }}: {{ parameter.type | typeName }}): void
15-
{
16-
this.{{ parameter.name | caseCamel | escapeKeyword }} = {{ parameter.name | caseCamel | escapeKeyword }};
17-
}
18-
public get{{ parameter.name | caseUcfirst | escapeKeyword }}(): {{ parameter.type | typeName }}
19-
{
20-
return this.{{ parameter.name | caseCamel | escapeKeyword }};
21-
}
22-
{% endfor %}
23-
constructor(client: Client, {% for parameter in service.globalParams %} {{ parameter.name | caseCamel | escapeKeyword }}:{{ parameter.type | typeName }}{% if not parameter.required %}|null = null{% endif %}{% if not loop.last %}, {% endif %}{% endfor %})
7+
constructor(client: Client)
248
{
259
super(client);
26-
27-
{% for parameter in service.globalParams %}
28-
this.{{ parameter.name | caseCamel | escapeKeyword }} = {{ parameter.name | caseCamel | escapeKeyword }};
29-
{% endfor %}
3010
}
31-
{% endif %}
3211
{% for method in service.methods %}
3312

3413
/**
@@ -38,34 +17,34 @@ export class {{ service.name | caseUcfirst }} extends Service {
3817
{{ method.description|comment3 }}
3918
{% endif %}
4019
*
41-
{% for parameter in method.parameters.all | filter((param) => not param.isGlobal) %}
20+
{% for parameter in method.parameters.all %}
4221
* @param {{ '{' }}{{ parameter.type | getPropertyType(method) | raw }}{{ '}' }} {{ parameter.name | caseCamel | escapeKeyword }}
4322
{% endfor %}
4423
* @throws {{ '{' }}{{ spec.title | caseUcfirst}}Exception}
4524
* @returns {% if method.type == 'webAuth' %}{void|string}{% elseif method.type == 'location' %}{URL}{% else %}{Promise}{% endif %}
4625

4726
*/
48-
{% if method.type != 'location' and method.type != 'webAuth'%}async {% endif %}{{ method.name | caseCamel }}{{ method.responseModel | getGenerics(spec) | raw }}({% for parameter in method.parameters.all | filter((param) => not param.isGlobal) %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %}?{% endif %}: {{ parameter.type | getPropertyType(method) | raw }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = (progress: UploadProgress) => {}{% endif %}): {{ method | getReturn(spec) | raw }} {
49-
{% for parameter in method.parameters.all | filter((param) => not param.isGlobal) %}
27+
{% if method.type != 'location' and method.type != 'webAuth'%}async {% endif %}{{ method.name | caseCamel }}{{ method.responseModel | getGenerics(spec) | raw }}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %}?{% endif %}: {{ parameter.type | getPropertyType(method) | raw }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = (progress: UploadProgress) => {}{% endif %}): {{ method | getReturn(spec) | raw }} {
28+
{% for parameter in method.parameters.all %}
5029
{% if parameter.required %}
5130
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} === 'undefined') {
5231
throw new {{spec.title | caseUcfirst}}Exception('Missing required parameter: "{{ parameter.name | caseCamel | escapeKeyword }}"');
5332
}
5433

5534
{% endif %}
5635
{% endfor %}
57-
let path = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel | escapeKeyword }}{{ '}' }}', {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }}){% endfor %};
36+
let path = '{{ method.path }}'{% for parameter in method.parameters.path %}.replace('{{ '{' }}{{ parameter.name | caseCamel | escapeKeyword }}{{ '}' }}', {{ parameter.name | caseCamel | escapeKeyword }}){% endfor %};
5837
let payload: Payload = {};
5938

6039
{% for parameter in method.parameters.query %}
61-
if (typeof {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
62-
payload['{{ parameter.name }}'] = {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }};
40+
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
41+
payload['{{ parameter.name }}'] = {{ parameter.name | caseCamel | escapeKeyword }};
6342
}
6443

6544
{% endfor %}
6645
{% for parameter in method.parameters.body %}
67-
if (typeof {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
68-
payload['{{ parameter.name }}'] = {% if parameter.isGlobal %}this.{% endif %}{{ parameter.name | caseCamel | escapeKeyword }};
46+
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} !== 'undefined') {
47+
payload['{{ parameter.name }}'] = {{ parameter.name | caseCamel | escapeKeyword }};
6948
}
7049

7150
{% endfor %}

0 commit comments

Comments
 (0)