Skip to content

Commit 9d3ed5d

Browse files
committed
feat(ama-sdk-schematics): remove dependencies in mock api generation (include breaking change)
1 parent 3a6a2d7 commit 9d3ed5d

File tree

2 files changed

+4
-42
lines changed

2 files changed

+4
-42
lines changed

packages/@ama-sdk/schematics/schematics/typescript/core/openapi-codegen-typescript/src/main/resources/typescriptFetch/spec/api-mock.mustache

+4-37
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
{{#apiInfo}}
2-
import { type ApiClient, isApiClient } from '@ama-sdk/core';
3-
import { ApiFetchClient, type BaseApiFetchClientConstructor } from '@ama-sdk/core';
2+
import type { ApiClient } from '@ama-sdk/core';
43

54
import * as api from '../api';
65

76
/**
8-
* Base path for the mock server
7+
* Mock Server default base path
98
*/
109
export const MOCK_SERVER_BASE_PATH = 'http://localhost:10010/v2';
11-
const MOCK_SERVER = new ApiFetchClient({basePath: MOCK_SERVER_BASE_PATH});
1210

1311
export interface Api {
1412
{{#apis}}
@@ -18,24 +16,6 @@ export interface Api {
1816
{{/apis}}
1917
}
2018

21-
/**
22-
* Mock APIs
23-
* @deprecated use `getMockedApi` with {@link ApiClient} instead, will be removed in v12.
24-
*/
25-
export const myApi: Api = {
26-
{{#noEmptyLines}}{{#trimComma}}{{#apis}}
27-
{{#operations}}
28-
{{#camelize}}{{classname}}{{/camelize}}: new api.{{classname}}(MOCK_SERVER),
29-
{{/operations}}
30-
{{/apis}}{{/trimComma}}{{/noEmptyLines}}
31-
};
32-
33-
/**
34-
* Retrieve mocked SDK Apis
35-
* @param config configuration of the Api Client
36-
* @deprecated use `getMockedApi` with {@link ApiClient} instead, will be removed in v12.
37-
*/
38-
export function getMockedApi(config?: string | BaseApiFetchClientConstructor): Api;
3919
/**
4020
* Retrieve mocked SDK Apis
4121
* @param apiClient Api Client instance
@@ -46,24 +26,11 @@ export function getMockedApi(config?: string | BaseApiFetchClientConstructor): A
4626
* const mocks = getMockedApi(new ApiFetchClient({ basePath: MOCK_SERVER_BASE_PATH }));
4727
* ```
4828
*/
49-
export function getMockedApi(apiClient: ApiClient): Api;
50-
/**
51-
* Retrieve mocked SDK Apis
52-
* @param config configuration of the Api Client
53-
*/
54-
export function getMockedApi(config?: string | BaseApiFetchClientConstructor | ApiClient): Api {
55-
let apiConfigObj: ApiClient = MOCK_SERVER;
56-
if (typeof config === 'string') {
57-
apiConfigObj = new ApiFetchClient({basePath: config});
58-
} else if (isApiClient(config)) {
59-
apiConfigObj = config;
60-
} else if (config) {
61-
apiConfigObj = new ApiFetchClient(config);
62-
}
29+
export function getMockedApi(apiClient: ApiClient): Api {
6330
return {
6431
{{#noEmptyLines}}{{#trimComma}}{{#apis}}
6532
{{#operations}}
66-
{{#camelize}}{{classname}}{{/camelize}}: new api.{{classname}}(apiConfigObj),
33+
{{#camelize}}{{classname}}{{/camelize}}: new api.{{classname}}(apiClient),
6734
{{/operations}}
6835
{{/apis}}{{/trimComma}}{{/noEmptyLines}}
6936
};

packages/@ama-sdk/schematics/schematics/typescript/shell/templates/base/package.json.template

-5
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@
6262
"peerDependenciesMeta": {
6363
"isomorphic-fetch": {
6464
"optional": true
65-
},
66-
"@ama-sdk/client-fetch": {
67-
"optional": true
6865
}
6966
},
7067
"devDependencies": {
@@ -80,7 +77,6 @@
8077
"@schematics/angular": "<%= angularVersion %>",
8178
"@commitlint/config-conventional": "<%= versions['@commitlint/config-conventional'] %>",
8279
"@ama-sdk/schematics": "<%= sdkCoreRange %>",
83-
"@ama-sdk/client-fetch": "<%= sdkCoreRange %>",
8480
"@ama-sdk/core": "<%= sdkCoreRange %>",
8581
"@o3r/eslint-config": "<%= sdkCoreRange %>",
8682
"@o3r/eslint-plugin": "<%= sdkCoreRange %>",
@@ -121,7 +117,6 @@
121117
"@o3r/schematics": "<%= sdkCoreRange %>"
122118
},<% } %>
123119
"peerDependencies": {
124-
"@ama-sdk/client-fetch": "<%= sdkCoreRange %>",
125120
"@ama-sdk/core": "~<%= sdkCoreVersion %>",
126121
"isomorphic-fetch": "<%= versions['isomorphic-fetch'] %>"
127122
},

0 commit comments

Comments
 (0)