openapi-ts-request 1.11.0 → 1.12.0

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.
@@ -0,0 +1,184 @@
1
+ import type { OpenAPIV3 } from 'openapi-types';
2
+ import type { ArraySchemaObject, ISchemaObject, OpenAPIObject, ParameterObject, ReferenceObject, ResponseObject, ResponsesObject, SchemaObject } from '../type';
3
+ import type { IPropObject, ITypeItem } from './type';
4
+ /**
5
+ * 解析对象类型参数
6
+ */
7
+ export interface ResolveObjectParams {
8
+ schemaObject: ISchemaObject;
9
+ openAPIData: OpenAPIObject;
10
+ config: {
11
+ namespace?: string;
12
+ isSupportParseEnumDesc?: boolean;
13
+ supportParseEnumDescByReg?: string | RegExp;
14
+ };
15
+ getType: (schemaObject: ISchemaObject, namespace?: string) => string;
16
+ resolveRefObject: <T>(refObject: ReferenceObject | T) => T;
17
+ }
18
+ /**
19
+ * 解析数组类型
20
+ */
21
+ export declare function resolveArray(params: {
22
+ schemaObject: ArraySchemaObject;
23
+ namespace?: string;
24
+ getType: (schemaObject: ISchemaObject, namespace?: string) => string;
25
+ }): {
26
+ type: string;
27
+ };
28
+ /**
29
+ * 解析属性
30
+ */
31
+ export declare function resolveProperties(params: {
32
+ schemaObject: SchemaObject;
33
+ getProps: (schemaObject: SchemaObject) => IPropObject[];
34
+ }): {
35
+ props: IPropObject[][];
36
+ };
37
+ /**
38
+ * 解析枚举对象
39
+ */
40
+ export declare function resolveEnumObject(params: {
41
+ schemaObject: SchemaObject;
42
+ config: {
43
+ isSupportParseEnumDesc?: boolean;
44
+ supportParseEnumDescByReg?: string | RegExp;
45
+ };
46
+ }): {
47
+ isEnum: boolean;
48
+ type: string;
49
+ enumLabelType: string;
50
+ description?: string;
51
+ };
52
+ /**
53
+ * 解析 allOf 对象
54
+ */
55
+ export declare function resolveAllOfObject(params: {
56
+ schemaObject: SchemaObject;
57
+ getType: (schemaObject: ISchemaObject) => string;
58
+ getProps: (schemaObject: SchemaObject) => IPropObject[];
59
+ }): {
60
+ props: (IPropObject[] | {
61
+ type: string;
62
+ }[])[];
63
+ };
64
+ /**
65
+ * 获取 TS 类型的属性列表
66
+ */
67
+ export declare function getProps(params: {
68
+ schemaObject: SchemaObject;
69
+ getType: (schema: SchemaObject) => string;
70
+ }): IPropObject[];
71
+ /**
72
+ * 解析参数引用
73
+ */
74
+ export declare function resolveParameterRef(params: {
75
+ param: ParameterObject | ReferenceObject;
76
+ openAPIData: OpenAPIObject;
77
+ }): ParameterObject | null;
78
+ /**
79
+ * 解析引用对象
80
+ */
81
+ export declare function resolveRefObject<T>(params: {
82
+ refObject: ReferenceObject | T;
83
+ openAPIData: OpenAPIObject;
84
+ resolveRefObjectFunc: (params: {
85
+ refObject: ReferenceObject | T;
86
+ openAPIData: OpenAPIObject;
87
+ resolveRefObjectFunc: (params: {
88
+ refObject: ReferenceObject | T;
89
+ openAPIData: OpenAPIObject;
90
+ resolveRefObjectFunc: any;
91
+ }) => T;
92
+ }) => T;
93
+ }): T;
94
+ /**
95
+ * 生成多状态码响应类型定义
96
+ */
97
+ export declare function getResponsesType(params: {
98
+ responses: ResponsesObject;
99
+ functionName: string;
100
+ interfaceTPConfigs: ITypeItem[];
101
+ components: OpenAPIV3.ComponentsObject;
102
+ getResponseTypeFromContentFunc: (params: {
103
+ response: ResponseObject;
104
+ components: OpenAPIV3.ComponentsObject;
105
+ }) => string;
106
+ resolveRefObjectFunc: <T>(refObject: ReferenceObject | T) => T;
107
+ }): string | null;
108
+ /**
109
+ * 解析响应条目
110
+ */
111
+ export declare function parseResponseEntries(params: {
112
+ responses: ResponsesObject;
113
+ components: OpenAPIV3.ComponentsObject;
114
+ getResponseTypeFromContentFunc: (params: {
115
+ response: ResponseObject;
116
+ components: OpenAPIV3.ComponentsObject;
117
+ }) => string;
118
+ resolveRefObjectFunc: <T>(refObject: ReferenceObject | T) => T;
119
+ }): Array<{
120
+ statusCode: string;
121
+ type: string;
122
+ description: string;
123
+ }>;
124
+ /**
125
+ * 从响应内容中提取 TypeScript 类型
126
+ */
127
+ export declare function getResponseTypeFromContent(params: {
128
+ response: ResponseObject;
129
+ components: OpenAPIV3.ComponentsObject;
130
+ config: {
131
+ dataFields?: string[];
132
+ binaryMediaTypes?: string[];
133
+ };
134
+ getType: (schema: SchemaObject) => string;
135
+ }): string;
136
+ /**
137
+ * 获取参数模板
138
+ */
139
+ export declare function getParamsTP(params: {
140
+ parameters?: (ParameterObject | ReferenceObject)[];
141
+ path?: string;
142
+ namespace?: string;
143
+ openAPIData: OpenAPIObject;
144
+ getType: (schema: ISchemaObject, namespace?: string) => string;
145
+ resolveParameterRefFunc: (params: {
146
+ param: ParameterObject | ReferenceObject;
147
+ openAPIData: OpenAPIObject;
148
+ }) => ParameterObject | null;
149
+ }): Record<string, ParameterObject[]>;
150
+ /**
151
+ * 分析类型定义中使用的类型名称
152
+ */
153
+ export declare function analyzeTypeReferences(types: ITypeItem[]): Set<string>;
154
+ /**
155
+ * 获取模块需要导入的类型
156
+ */
157
+ export declare function getModuleImports(params: {
158
+ moduleTypes: ITypeItem[];
159
+ commonTypes: ITypeItem[];
160
+ enumTypes: ITypeItem[];
161
+ }): {
162
+ commonImports: string[];
163
+ enumImports: string[];
164
+ };
165
+ /**
166
+ * 将公共类型依赖的类型从模块类型移到公共类型
167
+ * 同时检测跨模块引用,将被多个模块使用的类型移到公共类型
168
+ * @param moduleTypes 模块类型
169
+ * @param commonTypes 公共类型
170
+ */
171
+ export declare function moveCommonTypeDependenciesToCommon(params: {
172
+ moduleTypes: Map<string, ITypeItem[]>;
173
+ commonTypes: ITypeItem[];
174
+ }): void;
175
+ /**
176
+ * 解析文件模板
177
+ */
178
+ export declare function resolveFileTP(params: {
179
+ obj: SchemaObject;
180
+ resolveObjectFunc: (schemaObject: SchemaObject) => any;
181
+ }): Array<{
182
+ title: string;
183
+ multiple: boolean;
184
+ }>;