open-api-typescript-request-generator 0.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/README.md +26 -0
- package/bin/apits-gener +4 -0
- package/es/Generator.d.ts +43 -0
- package/es/Generator.js +892 -0
- package/es/cli.d.ts +19 -0
- package/es/cli.js +547 -0
- package/es/console.d.ts +48 -0
- package/es/console.js +151 -0
- package/es/constants.d.ts +22 -0
- package/es/constants.js +39 -0
- package/es/dependenciesHandler.d.ts +16 -0
- package/es/dependenciesHandler.js +270 -0
- package/es/genIndex.d.ts +23 -0
- package/es/genIndex.js +354 -0
- package/es/genRequest.d.ts +3 -0
- package/es/genRequest.js +216 -0
- package/es/getOutputPath.d.ts +5 -0
- package/es/getOutputPath.js +28 -0
- package/es/helpers.d.ts +63 -0
- package/es/helpers.js +458 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +34 -0
- package/es/requestYapiData.d.ts +157 -0
- package/es/requestYapiData.js +1010 -0
- package/es/responseDataJsonSchemaHandler.d.ts +11 -0
- package/es/responseDataJsonSchemaHandler.js +193 -0
- package/es/server/mock.d.ts +1 -0
- package/es/server/mock.js +7 -0
- package/es/server/swaggerJsonToYApiData.d.ts +10 -0
- package/es/server/swaggerJsonToYApiData.js +614 -0
- package/es/spinner.d.ts +15 -0
- package/es/spinner.js +58 -0
- package/es/types.d.ts +736 -0
- package/es/types.js +143 -0
- package/es/utils.d.ts +97 -0
- package/es/utils.js +783 -0
- package/lib/Generator.d.ts +43 -0
- package/lib/Generator.js +892 -0
- package/lib/cli.d.ts +19 -0
- package/lib/cli.js +547 -0
- package/lib/console.d.ts +48 -0
- package/lib/console.js +151 -0
- package/lib/constants.d.ts +22 -0
- package/lib/constants.js +39 -0
- package/lib/dependenciesHandler.d.ts +16 -0
- package/lib/dependenciesHandler.js +270 -0
- package/lib/genIndex.d.ts +23 -0
- package/lib/genIndex.js +354 -0
- package/lib/genRequest.d.ts +3 -0
- package/lib/genRequest.js +216 -0
- package/lib/getOutputPath.d.ts +5 -0
- package/lib/getOutputPath.js +28 -0
- package/lib/helpers.d.ts +63 -0
- package/lib/helpers.js +458 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +34 -0
- package/lib/requestYapiData.d.ts +157 -0
- package/lib/requestYapiData.js +1010 -0
- package/lib/responseDataJsonSchemaHandler.d.ts +11 -0
- package/lib/responseDataJsonSchemaHandler.js +193 -0
- package/lib/server/mock.d.ts +1 -0
- package/lib/server/mock.js +7 -0
- package/lib/server/swaggerJsonToYApiData.d.ts +10 -0
- package/lib/server/swaggerJsonToYApiData.js +614 -0
- package/lib/spinner.d.ts +15 -0
- package/lib/spinner.js +58 -0
- package/lib/types.d.ts +736 -0
- package/lib/types.js +143 -0
- package/lib/utils.d.ts +97 -0
- package/lib/utils.js +783 -0
- package/package.json +106 -0
package/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# api-ts-generator
|
2
|
+
|
3
|
+
基于 Yapi 或 Swagger,生成接口的 request、response 类型声明和请求方法体
|
4
|
+
|
5
|
+
## 版本更新
|
6
|
+
|
7
|
+
【2.0.0】破坏性改动,此改动将会影响接口函数名的生成,导致调用方需要同步修改生成后的调用名[CHANGELOG](https://github.com/huzhongchun/api-ts-generator/commit/748d6618cad84f3b01936921943433063b133203)
|
8
|
+
|
9
|
+
## 安装
|
10
|
+
|
11
|
+
`npm install api-ts-generator -g`
|
12
|
+
|
13
|
+
## 初始化生成配置文件
|
14
|
+
|
15
|
+
`apits-gener init`
|
16
|
+
|
17
|
+
|
18
|
+
## 生成接口
|
19
|
+
|
20
|
+
`apits-gener gen`
|
21
|
+
|
22
|
+
|
23
|
+
## 配置
|
24
|
+
|
25
|
+
参考开源代码:https://fjc0k.github.io/yapi-to-typescript/handbook/
|
26
|
+
|
package/bin/apits-gener
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
import { OpenAPIV3 } from 'openapi-types';
|
2
|
+
import { Config, ExtendedInterface, Interface, SyntheticalConfig, GeneratorOptions } from './types';
|
3
|
+
interface OutputFileList {
|
4
|
+
[outputFilePath: string]: {
|
5
|
+
projectId: string;
|
6
|
+
categoryId: string;
|
7
|
+
syntheticalConfig: SyntheticalConfig;
|
8
|
+
content: string[];
|
9
|
+
outputResponseDataJsonSchemaFilePath: string;
|
10
|
+
responseDataJsonSchemaContent: string[];
|
11
|
+
requestFunctionFilePath: string;
|
12
|
+
requestHookMakerFilePath: string;
|
13
|
+
};
|
14
|
+
}
|
15
|
+
export declare class Generator {
|
16
|
+
private options;
|
17
|
+
/** 配置 */
|
18
|
+
private config;
|
19
|
+
private disposes;
|
20
|
+
constructor(config: Config, options?: GeneratorOptions);
|
21
|
+
getOpenApiV3Json(url: string): Promise<OpenAPIV3.Document>;
|
22
|
+
/**
|
23
|
+
* 生成代码
|
24
|
+
* @returns
|
25
|
+
*/
|
26
|
+
generate(): Promise<OutputFileList>;
|
27
|
+
/**
|
28
|
+
* 写入文件
|
29
|
+
* @param outputFileList
|
30
|
+
* @returns
|
31
|
+
*/
|
32
|
+
write(outputFileList: OutputFileList): Promise<void[]>;
|
33
|
+
tsc(file: string): Promise<void>;
|
34
|
+
/** 请求函数名生成 */
|
35
|
+
requestFunctionNameGen(extendedInterfaceInfo: ExtendedInterface): string;
|
36
|
+
/** 生成接口代码 */
|
37
|
+
generateInterfaceCode(syntheticalConfig: SyntheticalConfig, interfaceInfo: Interface): Promise<{
|
38
|
+
code: string;
|
39
|
+
responseDataJsonSchema: string;
|
40
|
+
}>;
|
41
|
+
destroy(): Promise<any[]>;
|
42
|
+
}
|
43
|
+
export {};
|