|
1 | 1 | {{>header}}
|
2 | 2 |
|
3 |
| -import type { BaseHttpRequest } from './core'; |
4 |
| -import { {{{httpClientRequest}}} } from './core'; |
5 |
| -import type { ClientConfig } from './core'; |
| 3 | +import { BaseHttpRequest } from './core/BaseHttpRequest'; |
| 4 | +import type { OpenAPIConfig } from './core/OpenAPI'; |
| 5 | +import { {{{httpClientRequest}}} } from './core/{{{httpClientRequest}}}'; |
6 | 6 | {{#if services}}
|
7 |
| -import { |
8 | 7 | {{#each services}}
|
9 |
| - {{{name}}}, |
| 8 | +import { {{{name}}} } from './services/{{{name}}}'; |
10 | 9 | {{/each}}
|
11 |
| -} from './services'; |
12 | 10 | {{/if}}
|
13 | 11 | {{#if service}}
|
14 |
| -import { {{{service.name}}} } from './services'; |
| 12 | +import { {{{service.name}}} } from './services/{{{service.name}}}'; |
15 | 13 | {{/if}}
|
16 | 14 |
|
17 | 15 | export class {{{clientName}}} {{#if service}}extends {{{service.name}}} {{/if}}{
|
18 | 16 | {{#each services}}
|
19 | 17 | readonly {{{shortName}}}: {{{name}}};
|
20 | 18 | {{/each}}
|
| 19 | + readonly request: BaseHttpRequest; |
21 | 20 |
|
22 |
| - constructor(clientConfig: ClientConfig, httpClient: BaseHttpRequest = new {{{httpClientRequest}}}()) { |
23 |
| - const config = { |
24 |
| - baseUrl: clientConfig?.baseUrl ?? '{{{server}}}', |
25 |
| - version: clientConfig?.version ?? '{{{version}}}', |
26 |
| - withCredentials: clientConfig?.withCredentials ?? false, |
27 |
| - token: clientConfig?.token, |
28 |
| - username: clientConfig?.username, |
29 |
| - password: clientConfig?.password, |
30 |
| - headers: clientConfig?.headers, |
31 |
| - } |
| 21 | + constructor(openApiConfig?: OpenAPIConfig, HttpRequest: new (config: OpenAPIConfig) => BaseHttpRequest = {{{httpClientRequest}}}) { |
| 22 | + {{#if service}}const request{{else}}this.request{{/if}} = new HttpRequest({ |
| 23 | + BASE: openApiConfig?.BASE ?? '{{{server}}}', |
| 24 | + VERSION: openApiConfig?.VERSION ?? '{{{version}}}', |
| 25 | + WITH_CREDENTIALS: openApiConfig?.WITH_CREDENTIALS ?? false, |
| 26 | + TOKEN: openApiConfig?.TOKEN, |
| 27 | + USERNAME: openApiConfig?.USERNAME, |
| 28 | + PASSWORD: openApiConfig?.PASSWORD, |
| 29 | + HEADERS: openApiConfig?.HEADERS, |
| 30 | + }); |
32 | 31 | {{#if service}}
|
33 |
| - super(httpClient, config); |
| 32 | + super(request); |
| 33 | + this.request = request; |
34 | 34 | {{/if}}
|
35 | 35 | {{#each services}}
|
36 |
| - this.{{{shortName}}} = new {{{name}}}(httpClient, config); |
| 36 | + this.{{{shortName}}} = new {{{name}}}(this.request); |
37 | 37 | {{/each}}
|
38 | 38 | }
|
39 | 39 | }
|
0 commit comments