Skip to content

Commit 258e4de

Browse files
author
mkefd
committed
mappersmith import
1 parent 97181f7 commit 258e4de

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

bin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if (params.client === 'mappersmith' && params.name === undefined) {
3333
}
3434

3535
if (params.client === 'mappersmith') {
36-
console.log('INFO: --exportServices is forced to be false mappersmith client');
36+
console.log('INFO: --exportServices option is forced to be false for mappersmith client');
3737
params.exportServices = false;
3838
}
3939

src/templates/core/mappersmith/request.hbs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
1+
{{>header}}
2+
3+
14
import forge, { Middleware, Response } from 'mappersmith';
2-
{{!--import forge, { Client, Response } from 'mappersmith';--}}
35
{{#each services}}
46
{{#if imports}}
57
{{#each imports}}
68
import type { {{{this}}} } from '../models/{{{this}}}';
79
{{/each}}
810
{{/if}}
911
{{/each}}
10-
{{!----}}
11-
{{!--export type {{{clientName}}}Resource = {--}}
12-
{{!--{{#each services}}--}}
13-
{{!-- {{name}}: {--}}
14-
{{!-- {{#each operations}}--}}
15-
{{!-- {{name}}: {--}}
16-
{{!-- method: '{{method}}';--}}
17-
{{!-- path: '{{path}}';--}}
18-
{{!-- };--}}
19-
{{!-- {{/each}}--}}
20-
{{!-- };--}}
21-
{{!--{{/each}}--}}
22-
{{!--};--}}
2312

24-
export type {{{clientName}}}Client = {
13+
export type {{{clientName}}}MappersmithClient = {
2514
{{#each services}}
2615
{{name}}: {
2716
{{#each operations}}
@@ -79,4 +68,4 @@ export const {{{camelCase clientName}}}MappersmithClientFactory = ({
7968
},
8069
{{/each}}
8170
},
82-
}) as {{{clientName}}}Client;
71+
}) as {{{clientName}}}MappersmithClient;

src/templates/index.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
export { {{{clientName}}} } from './{{{clientName}}}';
55

66
{{/if}}
7+
{{#equals @root.httpClient 'mappersmith'}}
8+
{{else}}
79
{{#if @root.exportCore}}
810
export { ApiError } from './core/ApiError';
911
{{#if @root.exportClient}}
@@ -13,6 +15,7 @@ export { CancelablePromise, CancelError } from './core/CancelablePromise';
1315
export { OpenAPI } from './core/OpenAPI';
1416
export type { OpenAPIConfig } from './core/OpenAPI';
1517
{{/if}}
18+
{{/equals}}
1619
{{#if @root.exportModels}}
1720
{{#if models}}
1821

@@ -45,3 +48,8 @@ export { {{{name}}}{{{@root.postfixServices}}} } from './services/{{{name}}}{{{@
4548
{{/each}}
4649
{{/if}}
4750
{{/if}}
51+
52+
{{#equals @root.httpClient 'mappersmith'}}
53+
export type { {{clientName}}MappersmithClient } from './core/request';
54+
export { {{{camelCase clientName}}}MappersmithClientFactory } from './core/request';
55+
{{/equals}}

src/utils/writeClientCore.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { resolve } from 'path';
1+
import {resolve} from 'path';
22

3-
import type { Client } from '../client/interfaces/Client';
4-
import { HttpClient } from '../HttpClient';
5-
import type { Indent } from '../Indent';
6-
import { copyFile, exists, writeFile } from './fileSystem';
7-
import { formatIndentation as i } from './formatIndentation';
8-
import { getHttpRequestName } from './getHttpRequestName';
9-
import { isDefined } from './isDefined';
10-
import type { Templates } from './registerHandlebarTemplates';
3+
import type {Client} from '../client/interfaces/Client';
4+
import {HttpClient} from '../HttpClient';
5+
import type {Indent} from '../Indent';
6+
import {copyFile, exists, writeFile} from './fileSystem';
7+
import {formatIndentation as i} from './formatIndentation';
8+
import {getHttpRequestName} from './getHttpRequestName';
9+
import {isDefined} from './isDefined';
10+
import type {Templates} from './registerHandlebarTemplates';
1111

1212
/**
1313
* Generate OpenAPI core files, this includes the basic boilerplate code to handle requests.
@@ -38,11 +38,13 @@ export const writeClientCore = async (
3838
services: client.services,
3939
};
4040

41-
await writeFile(resolve(outputPath, 'OpenAPI.ts'), i(templates.core.settings(context), indent));
42-
await writeFile(resolve(outputPath, 'ApiError.ts'), i(templates.core.apiError(context), indent));
43-
await writeFile(resolve(outputPath, 'ApiRequestOptions.ts'), i(templates.core.apiRequestOptions(context), indent));
44-
await writeFile(resolve(outputPath, 'ApiResult.ts'), i(templates.core.apiResult(context), indent));
45-
await writeFile(resolve(outputPath, 'CancelablePromise.ts'), i(templates.core.cancelablePromise(context), indent));
41+
if (httpClient !== HttpClient.MAPPERSMITH) {
42+
await writeFile(resolve(outputPath, 'OpenAPI.ts'), i(templates.core.settings(context), indent));
43+
await writeFile(resolve(outputPath, 'ApiError.ts'), i(templates.core.apiError(context), indent));
44+
await writeFile(resolve(outputPath, 'ApiRequestOptions.ts'), i(templates.core.apiRequestOptions(context), indent));
45+
await writeFile(resolve(outputPath, 'ApiResult.ts'), i(templates.core.apiResult(context), indent));
46+
await writeFile(resolve(outputPath, 'CancelablePromise.ts'), i(templates.core.cancelablePromise(context), indent));
47+
}
4648
await writeFile(resolve(outputPath, 'request.ts'), i(templates.core.request(context), indent));
4749

4850
if (isDefined(clientName) && httpClient !== HttpClient.MAPPERSMITH) {

src/utils/writeClientIndex.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const writeClientIndex = async (
5353
models: sortModelsByName(client.models),
5454
services: sortServicesByName(client.services),
5555
exportClient: isDefined(clientName) && httpClient !== HttpClient.MAPPERSMITH,
56+
httpClient,
5657
});
5758

5859
await writeFile(resolve(outputPath, 'index.ts'), templateResult);

0 commit comments

Comments
 (0)