Skip to content

Commit 48834f4

Browse files
committed
Fix get methods, and d.ts docs
1 parent a27cdc6 commit 48834f4

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

templates/deno/src/services/service.ts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
4848
{
4949
this.{{ parameter.name | caseCamel | escapeKeyword }} = {{ parameter.name | caseCamel | escapeKeyword }};
5050
}
51-
public get{{ parameter.name | caseUcfirst | escapeKeyword }}({{ parameter.name | caseCamel | escapeKeyword }}: {{ parameter.type | typeName }}): {{ parameter.type | typeName }}
51+
public get{{ parameter.name | caseUcfirst | escapeKeyword }}(): {{ parameter.type | typeName }}
5252
{
5353
return this.{{ parameter.name | caseCamel | escapeKeyword }};
5454
}

templates/node/index.d.ts.twig

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { InputFile } from "./lib/inputFile";
2+
13
{% macro sub_schema(property, definition, spec) %}
24
{% apply spaceless %}
35
{% if property.sub_schema %}
@@ -126,6 +128,18 @@ declare module "{{ language.params.npmPackage|caseDash }}" {
126128
constructor(client: Client);
127129
}
128130

131+
export class InputFile {
132+
static fromPath(filePath: string, filename: string): InputFile;
133+
134+
static fromBuffer(buffer: Buffer, filename: string): InputFile;
135+
136+
static fromBlob(blob: Blob, filename: string): InputFile;
137+
138+
static fromStream(stream: any, filename: string, size: number): InputFile;
139+
140+
static fromPlainText(content: string, filename: string): InputFile;
141+
}
142+
129143
type QueryTypesSingle = string | number | boolean;
130144
type QueryTypesList = string[] | number[] | boolean[];
131145
type QueryTypes = QueryTypesSingle | QueryTypesList;
@@ -152,6 +166,27 @@ declare module "{{ language.params.npmPackage|caseDash }}" {
152166

153167
{% for service in spec.services %}
154168
export class {{ service.name | caseUcfirst }} extends Service {
169+
constructor(client: Client{% for parameter in service.globalParams %}, {{ parameter.name | caseCamel | escapeKeyword }}: {{ parameter.type | typeName }}{% if not parameter.required %}|null{% endif %}{% endfor %});
170+
171+
{% if service.globalParams | length %}
172+
{% for parameter in service.globalParams %}
173+
/**
174+
* Get {{ parameter.name }}.
175+
*
176+
* @returns {{ '{' }}{{ parameter.type | typeName }}{{ '}' }}
177+
*/
178+
get{{ parameter.name | caseUcfirst | escapeKeyword }}(): {{ parameter.type | typeName }};
179+
180+
/**
181+
* Set {{ parameter.name }}.
182+
*
183+
* @param {{ '{' }}{{ parameter.type | typeName }}{{ '}' }} {{ parameter.name | caseCamel | escapeKeyword }}
184+
* @returns {void}
185+
*/
186+
set{{ parameter.name | caseUcfirst | escapeKeyword }}({{ parameter.name | caseCamel | escapeKeyword }}: {{ parameter.type | typeName }}): void;
187+
188+
{% endfor %}
189+
{% endif %}
155190
{% for method in service.methods %}
156191
{% set generics = _self.get_generics_method(spec.definitions[method.responseModel], spec, true, true) %}
157192
{% set generics_return = _self.get_generics_method_return(spec.definitions[method.responseModel], spec) %}
@@ -162,13 +197,13 @@ declare module "{{ language.params.npmPackage|caseDash }}" {
162197
{{ method.description|comment1 }}
163198
*
164199
{% endif %}
165-
{% for parameter in method.parameters.all %}
200+
{% for parameter in method.parameters.all | filter((param) => not param.isGlobal) %}
166201
* @param {{ '{' }}{{ parameter.type | typeName }}{{ '}' }} {{ parameter.name | caseCamel }}
167202
{% endfor %}
168203
* @throws {{ '{' }}{{ spec.title | caseUcfirst}}Exception}
169204
* @returns {Promise}
170205
*/
171-
{{ method.name | caseCamel }}{% if generics %}<{{generics}}>{% endif %}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %}?{% endif %}: {{ parameter.type | typeName }}{% if not loop.last %}, {% endif %}{% endfor %}): Promise<{% if method.type == 'location' %}Buffer{% else %}{% if method.responseModel and method.responseModel != 'any' %}{% if not spec.definitions[method.responseModel].additionalProperties %}Models.{% endif %}{{method.responseModel | caseUcfirst}}{% if generics_return %}<{{generics_return}}>{% endif %}{% else %}Response{% endif %}{% endif %}>;
206+
{{ method.name | caseCamel }}{% if generics %}<{{generics}}>{% endif %}({% for parameter in method.parameters.all | filter((param) => not param.isGlobal) %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %}?{% endif %}: {{ parameter.type | typeName }}{% if not loop.last %}, {% endif %}{% endfor %}): Promise<{% if method.type == 'location' %}Buffer{% else %}{% if method.responseModel and method.responseModel != 'any' %}{% if not spec.definitions[method.responseModel].additionalProperties %}Models.{% endif %}{{method.responseModel | caseUcfirst}}{% if generics_return %}<{{generics_return}}>{% endif %}{% else %}Response{% endif %}{% endif %}>;
172207
{% endfor %}
173208
}
174209
{% endfor %}

templates/node/lib/services/service.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class {{ service.name | caseUcfirst }} extends Service {
2626
*
2727
* @return {{ parameter.type | typeName }}
2828
*/
29-
get{{ parameter.name | caseUcfirst | escapeKeyword }}({{ parameter.name | caseCamel | escapeKeyword }})
29+
get{{ parameter.name | caseUcfirst | escapeKeyword }}()
3030
{
3131
return this.{{ parameter.name | caseCamel | escapeKeyword }};
3232
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
1515
{
1616
this.{{ parameter.name | caseCamel | escapeKeyword }} = {{ parameter.name | caseCamel | escapeKeyword }};
1717
}
18-
public get{{ parameter.name | caseUcfirst | escapeKeyword }}({{ parameter.name | caseCamel | escapeKeyword }}: {{ parameter.type | typeName }}): {{ parameter.type | typeName }}
18+
public get{{ parameter.name | caseUcfirst | escapeKeyword }}(): {{ parameter.type | typeName }}
1919
{
2020
return this.{{ parameter.name | caseCamel | escapeKeyword }};
2121
}

0 commit comments

Comments
 (0)