Skip to content

Commit 5f58982

Browse files
committed
- Working solution for export client
1 parent e1268b1 commit 5f58982

25 files changed

+102
-138
lines changed

src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ export type Options = {
3939
* @param clientName Custom client class name
4040
* @param useOptions Use options or arguments functions
4141
* @param useUnionTypes Use union types instead of enums
42-
* @param exportCore: Generate core client classes
43-
* @param exportServices: Generate services
44-
* @param exportModels: Generate models
45-
* @param exportSchemas: Generate schemas
46-
* @param indent: Indentation options (4, 2 or tab)
47-
* @param postfix: Service name postfix
48-
* @param request: Path to custom request file
42+
* @param exportCore Generate core client classes
43+
* @param exportServices Generate services
44+
* @param exportModels Generate models
45+
* @param exportSchemas Generate schemas
46+
* @param indent Indentation options (4, 2 or tab)
47+
* @param postfix Service name postfix
48+
* @param request Path to custom request file
4949
* @param write Write the files to disk (true or false)
5050
*/
5151
export const generate = async ({

src/openApi/v2/parser/getOperation.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { OpenApiOperation } from '../interfaces/OpenApiOperation';
55
import { getOperationErrors } from './getOperationErrors';
66
import { getOperationName } from './getOperationName';
77
import { getOperationParameters } from './getOperationParameters';
8-
import { getOperationPath } from './getOperationPath';
98
import { getOperationResponseHeader } from './getOperationResponseHeader';
109
import { getOperationResponses } from './getOperationResponses';
1110
import { getOperationResults } from './getOperationResults';
@@ -22,7 +21,6 @@ export const getOperation = (
2221
): Operation => {
2322
const serviceName = getServiceName(tag);
2423
const operationName = getOperationName(op.operationId || `${method}`);
25-
const operationPath = getOperationPath(url);
2624

2725
// Create a new operation object for this method.
2826
const operation: Operation = {
@@ -32,7 +30,7 @@ export const getOperation = (
3230
description: op.description || null,
3331
deprecated: op.deprecated === true,
3432
method: method.toUpperCase(),
35-
path: operationPath,
33+
path: url,
3634
parameters: [...pathParams.parameters],
3735
parametersPath: [...pathParams.parametersPath],
3836
parametersQuery: [...pathParams.parametersQuery],

src/openApi/v2/parser/getOperationPath.spec.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/openApi/v2/parser/getOperationPath.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/openApi/v3/parser/getOperation.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type { OpenApiRequestBody } from '../interfaces/OpenApiRequestBody';
66
import { getOperationErrors } from './getOperationErrors';
77
import { getOperationName } from './getOperationName';
88
import { getOperationParameters } from './getOperationParameters';
9-
import { getOperationPath } from './getOperationPath';
109
import { getOperationRequestBody } from './getOperationRequestBody';
1110
import { getOperationResponseHeader } from './getOperationResponseHeader';
1211
import { getOperationResponses } from './getOperationResponses';
@@ -25,7 +24,6 @@ export const getOperation = (
2524
): Operation => {
2625
const serviceName = getServiceName(tag);
2726
const operationName = getOperationName(op.operationId || `${method}`);
28-
const operationPath = getOperationPath(url);
2927

3028
// Create a new operation object for this method.
3129
const operation: Operation = {
@@ -35,7 +33,7 @@ export const getOperation = (
3533
description: op.description || null,
3634
deprecated: op.deprecated === true,
3735
method: method.toUpperCase(),
38-
path: operationPath,
36+
path: url,
3937
parameters: [...pathParams.parameters],
4038
parametersPath: [...pathParams.parametersPath],
4139
parametersQuery: [...pathParams.parametersQuery],

src/openApi/v3/parser/getOperationPath.spec.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/openApi/v3/parser/getOperationPath.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/templates/client.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
1414

1515
export class {{{clientName}}} {
1616

17-
{{#each services}}
17+
{{#each services}}
1818
public readonly {{{camelCase name}}}: {{{name}}}{{{@root.postfix}}};
19-
{{/each}}
19+
{{/each}}
2020

2121
private readonly request: BaseHttpRequest;
2222

src/templates/core/ApiRequestOptions.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
export type ApiRequestOptions = {
44
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
5-
readonly path: string;
5+
readonly url: string;
6+
readonly path?: Record<string, any>;
67
readonly cookies?: Record<string, any>;
78
readonly headers?: Record<string, any>;
89
readonly query?: Record<string, any>;

src/templates/core/BaseHttpRequest.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { CancelablePromise } from './CancelablePromise';
55
import type { OpenAPIConfig } from './OpenAPI';
66

77
export class BaseHttpRequest {
8+
89
protected readonly config: OpenAPIConfig;
910

1011
constructor(config: OpenAPIConfig) {

0 commit comments

Comments
 (0)