Skip to content

Commit 017440e

Browse files
committed
feat(types): Add request configuration method to {{classname}}Interface
1 parent f659457 commit 017440e

1 file changed

Lines changed: 35 additions & 9 deletions

File tree

  • modules/openapi-generator/src/main/resources/typescript-fetch

modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ export interface {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterIn
4242
*/
4343
export interface {{classname}}Interface {
4444
{{#operation}}
45+
/**
46+
* Creates request configuration for {{nickname}} without sending the request
47+
{{#allParams}}
48+
* @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
49+
{{/allParams}}
50+
* @param {*} [options] Override http request option.
51+
{{#isDeprecated}}
52+
* @deprecated
53+
{{/isDeprecated}}
54+
* @throws {RequiredError}
55+
* @memberof {{classname}}Interface
56+
*/
57+
{{nickname}}RequestConfig({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.RequestOpts>;
58+
4559
/**
4660
* {{&notes}}
4761
{{#summary}}
@@ -95,17 +109,12 @@ export class {{classname}} extends runtime.BaseAPI {
95109

96110
{{#operation}}
97111
/**
98-
{{#notes}}
99-
* {{&notes}}
100-
{{/notes}}
101-
{{#summary}}
102-
* {{&summary}}
103-
{{/summary}}
112+
* Creates request configuration for {{nickname}} without sending the request
104113
{{#isDeprecated}}
105114
* @deprecated
106115
{{/isDeprecated}}
107116
*/
108-
async {{nickname}}Raw({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<{{{returnType}}}{{^returnType}}void{{/returnType}}>> {
117+
async {{nickname}}RequestConfig({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.RequestOpts> {
109118
{{#allParams}}
110119
{{#required}}
111120
if (requestParameters['{{paramName}}'] == null) {
@@ -302,7 +311,7 @@ export class {{classname}} extends runtime.BaseAPI {
302311
{{/isDateTimeType}}
303312
{{/pathParams}}
304313

305-
const response = await this.request({
314+
const requestOpts: runtime.RequestOpts = {
306315
path: urlPath,
307316
method: '{{httpMethod}}',
308317
headers: headerParameters,
@@ -335,7 +344,24 @@ export class {{classname}} extends runtime.BaseAPI {
335344
{{#hasFormParams}}
336345
body: formParams,
337346
{{/hasFormParams}}
338-
}, initOverrides);
347+
};
348+
return requestOpts;
349+
}
350+
351+
/**
352+
{{#notes}}
353+
* {{&notes}}
354+
{{/notes}}
355+
{{#summary}}
356+
* {{&summary}}
357+
{{/summary}}
358+
{{#isDeprecated}}
359+
* @deprecated
360+
{{/isDeprecated}}
361+
*/
362+
async {{nickname}}Raw({{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}Request, {{/allParams.0}}initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<{{{returnType}}}{{^returnType}}void{{/returnType}}>> {
363+
const requestConfig = await this.{{nickname}}RequestConfig({{#allParams.0}}requestParameters, {{/allParams.0}}initOverrides);
364+
const response = await this.request(requestConfig, initOverrides);
339365

340366
{{#returnType}}
341367
{{#isResponseFile}}

0 commit comments

Comments
 (0)