Skip to content

Commit 22687b3

Browse files
Запасной Александр СергеевичЗапасной Александр Сергеевич
authored andcommitted
Fixed bug
1 parent 80f64ce commit 22687b3

File tree

7 files changed

+9
-608
lines changed

7 files changed

+9
-608
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sundved/openapi-typescript-codegen",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "Fork of library that generates Typescript clients based on the OpenAPI specification.",
55
"author": "Sundved",
66
"homepage": "https://github.com/Sundved/openapi-typescript-codegen",

src/templates/core/httpClient/request.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{{>header}}
2+
3+
import { DELETE, GET, POST, PUT } from '{{{httpClientLibrary}}}';
24
import type { ApiRequestOptions } from './ApiRequestOptions';
35
import { OpenAPI } from './OpenAPI';
46

src/templates/core/httpClient/sendRequest.hbs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import {DELETE, GET, POST, PUT} from '{{>httpClientLibrary}}';
2-
31
async function sendRequest(options: ApiRequestOptions, url: string): Promise<any> {
42

53
switch (options.method) {

src/utils/writeClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ export async function writeClient(
5151
if (exportCore) {
5252
await rmdir(outputPathCore);
5353
await mkdir(outputPathCore);
54-
await writeClientCore(client, templates, outputPathCore, httpClient);
54+
await writeClientCore(client, templates, outputPathCore, httpClient, httpClientLibrary);
5555
}
5656

5757
if (exportServices) {
5858
await rmdir(outputPathServices);
5959
await mkdir(outputPathServices);
60-
await writeClientServices(client.services, templates, outputPathServices, httpClient, useUnionTypes, useOptions, httpClientLibrary);
60+
await writeClientServices(client.services, templates, outputPathServices, httpClient, useUnionTypes, useOptions);
6161
}
6262

6363
if (exportSchemas) {

src/utils/writeClientCore.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import { Templates } from './registerHandlebarTemplates';
1111
* @param templates The loaded handlebar templates
1212
* @param outputPath Directory to write the generated files to
1313
* @param httpClient The selected httpClient (fetch, xhr or node)
14+
* @param httpClientLibrary Library for httpClient
1415
*/
15-
export async function writeClientCore(client: Client, templates: Templates, outputPath: string, httpClient: HttpClient): Promise<void> {
16+
export async function writeClientCore(client: Client, templates: Templates, outputPath: string, httpClient: HttpClient, httpClientLibrary: string): Promise<void> {
1617
const context = {
1718
httpClient,
19+
httpClientLibrary,
1820
server: client.server,
1921
version: client.version,
2022
};

src/utils/writeClientServices.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,8 @@ const VERSION_TEMPLATE_STRING = 'OpenAPI.VERSION';
1616
* @param httpClient The selected httpClient (fetch, xhr or node)
1717
* @param useUnionTypes Use union types instead of enums
1818
* @param useOptions Use options or arguments functions
19-
* @param httpClientLibrary Library for httpClient
2019
*/
21-
export async function writeClientServices(
22-
services: Service[],
23-
templates: Templates,
24-
outputPath: string,
25-
httpClient: HttpClient,
26-
useUnionTypes: boolean,
27-
useOptions: boolean,
28-
httpClientLibrary: string
29-
): Promise<void> {
20+
export async function writeClientServices(services: Service[], templates: Templates, outputPath: string, httpClient: HttpClient, useUnionTypes: boolean, useOptions: boolean): Promise<void> {
3021
for (const service of services) {
3122
const file = path.resolve(outputPath, `${service.name}.ts`);
3223
const useVersion = service.operations.some(operation => operation.path.includes(VERSION_TEMPLATE_STRING));
@@ -36,7 +27,6 @@ export async function writeClientServices(
3627
useUnionTypes,
3728
useVersion,
3829
useOptions,
39-
httpClientLibrary,
4030
});
4131
await writeFile(file, format(templateResult));
4232
}

0 commit comments

Comments
 (0)