|
1 | 1 | {{>header}}
|
2 | 2 |
|
3 |
| -{{#equals @root.httpClient 'angular'}} |
4 |
| -{{#if @root.exportClient}} |
5 |
| -import { Injectable } from '@angular/core'; |
6 |
| -import type { Observable } from 'rxjs'; |
7 |
| -{{else}} |
8 |
| -import { Injectable } from '@angular/core'; |
9 |
| -import { HttpClient } from '@angular/common/http'; |
10 |
| -import type { Observable } from 'rxjs'; |
11 |
| -{{/if}} |
12 |
| - |
13 |
| -{{/equals}} |
14 | 3 | {{#if imports}}
|
15 | 4 | {{#each imports}}
|
16 |
| -import type { {{{this}}} } from '../models/{{{this}}}'; |
| 5 | +import type { {{~this~}} } from '../models/{{{this}}}'; |
17 | 6 | {{/each}}
|
18 |
| - |
19 | 7 | {{/if}}
|
20 |
| -{{#notEquals @root.httpClient 'angular'}} |
21 |
| -import type { CancelablePromise } from '../core/CancelablePromise'; |
22 |
| -{{/notEquals}} |
23 |
| -{{#if @root.exportClient}} |
24 |
| -{{#equals @root.httpClient 'angular'}} |
25 |
| -import { BaseHttpRequest } from '../core/BaseHttpRequest'; |
26 |
| -{{else}} |
27 |
| -import type { BaseHttpRequest } from '../core/BaseHttpRequest'; |
28 |
| -{{/equals}} |
29 |
| -{{else}} |
| 8 | +import {request as __request} from '../core/request'; |
| 9 | +{{#if @root.useVersion}} |
30 | 10 | import { OpenAPI } from '../core/OpenAPI';
|
31 |
| -import { request as __request } from '../core/request'; |
32 | 11 | {{/if}}
|
33 | 12 |
|
34 |
| -{{#equals @root.httpClient 'angular'}} |
35 |
| -@Injectable({ |
36 |
| - providedIn: 'root', |
37 |
| -}) |
38 |
| -{{/equals}} |
39 | 13 | export class {{{name}}}{{{@root.postfix}}} {
|
40 |
| - {{#if @root.exportClient}} |
41 |
| - |
42 |
| - constructor(public readonly httpRequest: BaseHttpRequest) {} |
43 |
| - {{else}} |
44 |
| - {{#equals @root.httpClient 'angular'}} |
45 |
| - |
46 |
| - constructor(public readonly http: HttpClient) {} |
47 |
| - {{/equals}} |
48 |
| - {{/if}} |
49 | 14 |
|
50 |
| - {{#each operations}} |
51 |
| - /** |
52 |
| - {{#if deprecated}} |
53 |
| - * @deprecated |
54 |
| - {{/if}} |
55 |
| - {{#if summary}} |
56 |
| - * {{{escapeComment summary}}} |
57 |
| - {{/if}} |
58 |
| - {{#if description}} |
59 |
| - * {{{escapeComment description}}} |
60 |
| - {{/if}} |
61 |
| - {{#unless @root.useOptions}} |
62 |
| - {{#if parameters}} |
63 |
| - {{#each parameters}} |
64 |
| - * @param {{{name}}} {{#if description}}{{{escapeComment description}}}{{/if}} |
65 |
| - {{/each}} |
66 |
| - {{/if}} |
67 |
| - {{/unless}} |
68 |
| - {{#each results}} |
69 |
| - * @returns {{{type}}} {{#if description}}{{{escapeComment description}}}{{/if}} |
70 |
| - {{/each}} |
71 |
| - * @throws ApiError |
72 |
| - */ |
73 |
| - {{#if @root.exportClient}} |
74 |
| - {{#equals @root.httpClient 'angular'}} |
75 |
| - public {{{name}}}({{>parameters}}): Observable<{{>result}}> { |
76 |
| - return this.httpRequest.request({ |
77 |
| - {{else}} |
78 |
| - public {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> { |
79 |
| - return this.httpRequest.request({ |
80 |
| - {{/equals}} |
81 |
| - {{else}} |
82 |
| - {{#equals @root.httpClient 'angular'}} |
83 |
| - public {{{name}}}({{>parameters}}): Observable<{{>result}}> { |
84 |
| - return __request(OpenAPI, this.http, { |
85 |
| - {{else}} |
86 |
| - public static {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> { |
87 |
| - return __request(OpenAPI, { |
88 |
| - {{/equals}} |
89 |
| - {{/if}} |
90 |
| - method: '{{{method}}}', |
91 |
| - url: '{{{path}}}', |
92 |
| - {{#if parametersPath}} |
93 |
| - path: { |
94 |
| - {{#each parametersPath}} |
95 |
| - '{{{prop}}}': {{{name}}}, |
96 |
| - {{/each}} |
97 |
| - }, |
98 |
| - {{/if}} |
99 |
| - {{#if parametersCookie}} |
100 |
| - cookies: { |
101 |
| - {{#each parametersCookie}} |
102 |
| - '{{{prop}}}': {{{name}}}, |
103 |
| - {{/each}} |
104 |
| - }, |
105 |
| - {{/if}} |
106 |
| - {{#if parametersHeader}} |
107 |
| - headers: { |
108 |
| - {{#each parametersHeader}} |
109 |
| - '{{{prop}}}': {{{name}}}, |
110 |
| - {{/each}} |
111 |
| - }, |
112 |
| - {{/if}} |
113 |
| - {{#if parametersQuery}} |
114 |
| - query: { |
115 |
| - {{#each parametersQuery}} |
116 |
| - '{{{prop}}}': {{{name}}}, |
117 |
| - {{/each}} |
118 |
| - }, |
119 |
| - {{/if}} |
120 |
| - {{#if parametersForm}} |
121 |
| - formData: { |
122 |
| - {{#each parametersForm}} |
123 |
| - '{{{prop}}}': {{{name}}}, |
124 |
| - {{/each}} |
125 |
| - }, |
126 |
| - {{/if}} |
127 |
| - {{#if parametersBody}} |
128 |
| - {{#equals parametersBody.in 'formData'}} |
129 |
| - formData: {{{parametersBody.name}}}, |
130 |
| - {{/equals}} |
131 |
| - {{#equals parametersBody.in 'body'}} |
132 |
| - body: {{{parametersBody.name}}}, |
133 |
| - {{/equals}} |
134 |
| - {{#if parametersBody.mediaType}} |
135 |
| - mediaType: '{{{parametersBody.mediaType}}}', |
136 |
| - {{/if}} |
137 |
| - {{/if}} |
138 |
| - {{#if responseHeader}} |
139 |
| - responseHeader: '{{{responseHeader}}}', |
140 |
| - {{/if}} |
141 |
| - {{#if errors}} |
142 |
| - errors: { |
143 |
| - {{#each errors}} |
144 |
| - {{{code}}}: `{{{escapeDescription description}}}`, |
145 |
| - {{/each}} |
146 |
| - }, |
147 |
| - {{/if}} |
148 |
| - }); |
149 |
| - } |
| 15 | + {{#each operations}} |
| 16 | + public static {{{name}}}({{>parameters}}) { |
| 17 | + return __request<{{>result}}>({ |
| 18 | + method: '{{{method}}}', |
| 19 | + path: `{{{path}}}`, |
| 20 | + {{#if parametersCookie}} |
| 21 | + cookies: { |
| 22 | + {{#each parametersCookie}} |
| 23 | + '{{{prop}}}': {{{name}}}, |
| 24 | + {{/each}} |
| 25 | + }, |
| 26 | + {{/if}} |
| 27 | + {{#if parametersHeader}} |
| 28 | + headers: { |
| 29 | + {{#each parametersHeader}} |
| 30 | + '{{{prop}}}': {{{name}}}, |
| 31 | + {{/each}} |
| 32 | + }, |
| 33 | + {{/if}} |
| 34 | + {{#if parametersQuery}} |
| 35 | + query: { |
| 36 | + {{#each parametersQuery}} |
| 37 | + '{{{prop}}}': {{{name}}}, |
| 38 | + {{/each}} |
| 39 | + }, |
| 40 | + {{/if}} |
| 41 | + {{#if parametersForm}} |
| 42 | + formData: { |
| 43 | + {{#each parametersForm}} |
| 44 | + '{{{prop}}}': {{{name}}}, |
| 45 | + {{/each}} |
| 46 | + }, |
| 47 | + {{/if}} |
| 48 | + {{#if parametersBody}} |
| 49 | + {{#equals parametersBody.in 'formData'}} |
| 50 | + formData: {{{parametersBody.name}}}, |
| 51 | + {{/equals}} |
| 52 | + {{#equals parametersBody.in 'body'}} |
| 53 | + body: {{{parametersBody.name}}}, |
| 54 | + {{/equals}} |
| 55 | + {{#if parametersBody.mediaType}} |
| 56 | + mediaType: '{{{parametersBody.mediaType}}}', |
| 57 | + {{/if}} |
| 58 | + {{/if}} |
| 59 | + {{#if responseHeader}} |
| 60 | + responseHeader: '{{{responseHeader}}}', |
| 61 | + {{/if}} |
| 62 | + {{#if errors}} |
| 63 | + errors: { |
| 64 | + {{#each errors}} |
| 65 | + {{{code}}}: `{{{description}}}`, |
| 66 | + {{/each}} |
| 67 | + }, |
| 68 | + {{/if}} |
| 69 | + }); |
| 70 | + } |
150 | 71 |
|
151 |
| - {{/each}} |
| 72 | + {{/each}} |
152 | 73 | }
|
0 commit comments