yapi-apifox-to-typescript 4.2.3 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/ApifoxToYApiData.js +312 -588
- package/lib/cjs/Generator.js +507 -1171
- package/lib/cjs/SwaggerToYApiServer.js +125 -336
- package/lib/cjs/_virtual/_rolldown/runtime.js +23 -0
- package/lib/cjs/cli.js +171 -280
- package/lib/cjs/helpers.js +125 -209
- package/lib/cjs/index.js +15 -19
- package/lib/cjs/mini-ut.js +220 -0
- package/lib/cjs/swaggerJsonToYApiData.js +268 -482
- package/lib/cjs/types.js +93 -93
- package/lib/cjs/utils.js +364 -769
- package/lib/esm/ApifoxToYApiData.d.ts +49 -0
- package/lib/esm/ApifoxToYApiData.js +310 -572
- package/lib/esm/Generator.d.ts +53 -0
- package/lib/esm/Generator.js +503 -1146
- package/lib/esm/SwaggerToYApiServer.d.ts +23 -0
- package/lib/esm/SwaggerToYApiServer.js +119 -317
- package/lib/esm/_virtual/_rolldown/runtime.js +7 -0
- package/lib/esm/cli.d.ts +4 -0
- package/lib/esm/cli.js +162 -251
- package/lib/esm/helpers.d.ts +49 -0
- package/lib/esm/helpers.js +125 -198
- package/lib/esm/index.d.ts +2 -897
- package/lib/esm/index.js +3 -2
- package/lib/esm/mini-ut.d.ts +105 -0
- package/lib/esm/mini-ut.js +198 -0
- package/lib/esm/swaggerJsonToYApiData.d.ts +6 -0
- package/lib/esm/swaggerJsonToYApiData.js +265 -469
- package/lib/esm/types.d.ts +698 -0
- package/lib/esm/types.js +87 -73
- package/lib/esm/utils.d.ts +95 -0
- package/lib/esm/utils.js +350 -720
- package/package.json +49 -59
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Category, CategoryConfig, InterfaceList, Project, SyntheticalConfig } from './types';
|
|
2
|
+
export interface ApifoxToYApiDataOptions {
|
|
3
|
+
token: string;
|
|
4
|
+
projectId: number;
|
|
5
|
+
categories: CategoryConfig[];
|
|
6
|
+
serverUrl: string;
|
|
7
|
+
addFoldersToTags?: boolean;
|
|
8
|
+
oasVersion?: string;
|
|
9
|
+
exportFormat?: 'JSON' | 'YAML';
|
|
10
|
+
}
|
|
11
|
+
export type TProjectInfo = Project & {
|
|
12
|
+
cats: Category[];
|
|
13
|
+
getMockUrl: () => string;
|
|
14
|
+
getDevUrl: (value: string) => string;
|
|
15
|
+
getProdUrl: (value: string) => string;
|
|
16
|
+
};
|
|
17
|
+
export declare class ApifoxToYApiData {
|
|
18
|
+
private openApiDoc;
|
|
19
|
+
private options;
|
|
20
|
+
private project;
|
|
21
|
+
private schemas;
|
|
22
|
+
private interfaceIdCounter;
|
|
23
|
+
constructor(options: ApifoxToYApiDataOptions);
|
|
24
|
+
private resolveRef;
|
|
25
|
+
private resolveSchema;
|
|
26
|
+
private getSchemaType;
|
|
27
|
+
private getRequestParamType;
|
|
28
|
+
private getRequestQueryType;
|
|
29
|
+
private convertParametersToReqParams;
|
|
30
|
+
private convertRequestBody;
|
|
31
|
+
private normalizeSchema;
|
|
32
|
+
private convertResponse;
|
|
33
|
+
private generateInterfaceId;
|
|
34
|
+
/**
|
|
35
|
+
* 获取接口所属的目录名称
|
|
36
|
+
* Apifox 优先使用 x-apifox-folder 字段,其次才用 tags[0]
|
|
37
|
+
*/
|
|
38
|
+
private getOperationFolder;
|
|
39
|
+
private convertOperationToInterface;
|
|
40
|
+
getProjectInfo(): Promise<TProjectInfo>;
|
|
41
|
+
private getTagId;
|
|
42
|
+
/**
|
|
43
|
+
* 从 OpenAPI tags 中获取目录对应的 tag
|
|
44
|
+
* 如果 x-apifox-folder 在 tags 中存在,则返回对应的 tag;否则返回 x-apifox-folder 本身
|
|
45
|
+
*/
|
|
46
|
+
private getMatchingTag;
|
|
47
|
+
getCats(cats: CategoryConfig): number[];
|
|
48
|
+
getInterfaceList(syntheticalConfig: SyntheticalConfig): Promise<InterfaceList>;
|
|
49
|
+
}
|