@dazhicheng/openapi 1.1.4 → 1.1.6

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.
@@ -1,460 +0,0 @@
1
- import type { OpenAPIObject, OperationObject, ParameterObject, ReferenceObject, RequestBodyObject, ResponsesObject, SchemaObject } from "openapi3-ts";
2
- import type { GenerateServiceProps } from "./index";
3
- export type TypescriptFileType = "interface" | "serviceController" | "serviceIndex";
4
- export interface APIDataType extends OperationObject {
5
- path: string;
6
- method: string;
7
- }
8
- export type TagAPIDataType = Record<string, APIDataType[]>;
9
- export interface MappingItemType {
10
- antTechApi: string;
11
- popAction: string;
12
- popProduct: string;
13
- antTechVersion: string;
14
- }
15
- export interface ControllerType {
16
- fileName: string;
17
- controllerName: string;
18
- }
19
- export declare const getPath: () => string;
20
- export declare const getGenInfo: (isDirExist: boolean, appName: string, absSrcPath: string) => boolean[];
21
- declare class ServiceGenerator {
22
- protected apiData: TagAPIDataType;
23
- protected classNameList: ControllerType[];
24
- protected version: string;
25
- protected mappings: MappingItemType[];
26
- protected finalPath: string;
27
- protected config: GenerateServiceProps;
28
- protected openAPIData: OpenAPIObject;
29
- constructor(config: GenerateServiceProps, openAPIData: OpenAPIObject);
30
- genFile(): Promise<void>;
31
- concatOrNull: (...arrays: any[]) => never[] | null;
32
- getFuncationName(data: APIDataType): string;
33
- getTypeName(data: APIDataType): string;
34
- getServiceTP(): {
35
- genType: string;
36
- className: string;
37
- instanceName: string;
38
- list: {
39
- functionName: string;
40
- typeName: string;
41
- path: string;
42
- pathInComment: string;
43
- hasPathVariables: boolean;
44
- hasApiPrefix: boolean;
45
- method: string;
46
- desc: string | undefined;
47
- hasHeader: boolean;
48
- params: Record<string, ParameterObject[]>;
49
- hasParams: boolean;
50
- options: Record<string, any>;
51
- body: {
52
- required: any;
53
- propertiesList: ({
54
- key: string;
55
- schema: {
56
- type: string;
57
- required: boolean;
58
- $ref: string;
59
- } | {
60
- type: string;
61
- required: boolean;
62
- nullable?: boolean;
63
- discriminator?: import("openapi3-ts").DiscriminatorObject;
64
- readOnly?: boolean;
65
- writeOnly?: boolean;
66
- xml?: import("openapi3-ts").XmlObject;
67
- externalDocs?: import("openapi3-ts").ExternalDocumentationObject;
68
- example?: any;
69
- examples?: any[];
70
- deprecated?: boolean;
71
- format?: "int32" | "int64" | "float" | "double" | "byte" | "binary" | "date" | "date-time" | "password" | string;
72
- allOf?: (SchemaObject | ReferenceObject)[];
73
- oneOf?: (SchemaObject | ReferenceObject)[];
74
- anyOf?: (SchemaObject | ReferenceObject)[];
75
- not?: SchemaObject | ReferenceObject;
76
- items?: SchemaObject | ReferenceObject;
77
- properties?: {
78
- [propertyName: string]: SchemaObject | ReferenceObject;
79
- };
80
- additionalProperties?: SchemaObject | ReferenceObject | boolean;
81
- description?: string;
82
- default?: any;
83
- title?: string;
84
- multipleOf?: number;
85
- maximum?: number;
86
- exclusiveMaximum?: boolean;
87
- minimum?: number;
88
- exclusiveMinimum?: boolean;
89
- maxLength?: number;
90
- minLength?: number;
91
- pattern?: string;
92
- maxItems?: number;
93
- minItems?: number;
94
- uniqueItems?: boolean;
95
- maxProperties?: number;
96
- minProperties?: number;
97
- enum?: any[];
98
- };
99
- } | undefined)[];
100
- nullable?: boolean;
101
- discriminator?: import("openapi3-ts").DiscriminatorObject;
102
- readOnly?: boolean;
103
- writeOnly?: boolean;
104
- xml?: import("openapi3-ts").XmlObject;
105
- externalDocs?: import("openapi3-ts").ExternalDocumentationObject;
106
- example?: any;
107
- examples?: any[];
108
- deprecated?: boolean;
109
- type?: "integer" | "number" | "string" | "boolean" | "object" | "null" | "array";
110
- format?: "int32" | "int64" | "float" | "double" | "byte" | "binary" | "date" | "date-time" | "password" | string;
111
- allOf?: (SchemaObject | ReferenceObject)[];
112
- oneOf?: (SchemaObject | ReferenceObject)[];
113
- anyOf?: (SchemaObject | ReferenceObject)[];
114
- not?: SchemaObject | ReferenceObject;
115
- items?: SchemaObject | ReferenceObject;
116
- properties?: {
117
- [propertyName: string]: SchemaObject | ReferenceObject;
118
- };
119
- additionalProperties?: SchemaObject | ReferenceObject | boolean;
120
- description?: string;
121
- default?: any;
122
- title?: string;
123
- multipleOf?: number;
124
- maximum?: number;
125
- exclusiveMaximum?: boolean;
126
- minimum?: number;
127
- exclusiveMinimum?: boolean;
128
- maxLength?: number;
129
- minLength?: number;
130
- pattern?: string;
131
- maxItems?: number;
132
- minItems?: number;
133
- uniqueItems?: boolean;
134
- maxProperties?: number;
135
- minProperties?: number;
136
- enum?: any[];
137
- mediaType: string | undefined;
138
- } | {
139
- mediaType: string | undefined;
140
- required: any;
141
- type: string;
142
- } | null;
143
- file: any;
144
- hasFormData: boolean;
145
- response: {
146
- mediaType: string;
147
- type: string;
148
- };
149
- tags?: string[];
150
- summary?: string;
151
- description?: string;
152
- externalDocs?: import("openapi3-ts").ExternalDocumentationObject;
153
- operationId?: string;
154
- parameters?: (ParameterObject | ReferenceObject)[];
155
- requestBody?: RequestBodyObject | ReferenceObject;
156
- responses: ResponsesObject;
157
- callbacks?: import("openapi3-ts").CallbacksObject;
158
- deprecated?: boolean;
159
- security?: import("openapi3-ts").SecurityRequirementObject[];
160
- servers?: import("openapi3-ts").ServerObject[];
161
- }[];
162
- }[];
163
- getBodyTP(requestBody?: any): {
164
- required: any;
165
- propertiesList: ({
166
- key: string;
167
- schema: {
168
- type: string;
169
- required: boolean;
170
- $ref: string;
171
- } | {
172
- type: string;
173
- required: boolean;
174
- nullable?: boolean;
175
- discriminator?: import("openapi3-ts").DiscriminatorObject;
176
- readOnly?: boolean;
177
- writeOnly?: boolean;
178
- xml?: import("openapi3-ts").XmlObject;
179
- externalDocs?: import("openapi3-ts").ExternalDocumentationObject;
180
- example?: any;
181
- examples?: any[];
182
- deprecated?: boolean;
183
- format?: "int32" | "int64" | "float" | "double" | "byte" | "binary" | "date" | "date-time" | "password" | string;
184
- allOf?: (SchemaObject | ReferenceObject)[];
185
- oneOf?: (SchemaObject | ReferenceObject)[];
186
- anyOf?: (SchemaObject | ReferenceObject)[];
187
- not?: SchemaObject | ReferenceObject;
188
- items?: SchemaObject | ReferenceObject;
189
- properties?: {
190
- [propertyName: string]: SchemaObject | ReferenceObject;
191
- };
192
- additionalProperties?: SchemaObject | ReferenceObject | boolean;
193
- description?: string;
194
- default?: any;
195
- title?: string;
196
- multipleOf?: number;
197
- maximum?: number;
198
- exclusiveMaximum?: boolean;
199
- minimum?: number;
200
- exclusiveMinimum?: boolean;
201
- maxLength?: number;
202
- minLength?: number;
203
- pattern?: string;
204
- maxItems?: number;
205
- minItems?: number;
206
- uniqueItems?: boolean;
207
- maxProperties?: number;
208
- minProperties?: number;
209
- enum?: any[];
210
- };
211
- } | undefined)[];
212
- nullable?: boolean;
213
- discriminator?: import("openapi3-ts").DiscriminatorObject;
214
- readOnly?: boolean;
215
- writeOnly?: boolean;
216
- xml?: import("openapi3-ts").XmlObject;
217
- externalDocs?: import("openapi3-ts").ExternalDocumentationObject;
218
- example?: any;
219
- examples?: any[];
220
- deprecated?: boolean;
221
- type?: "integer" | "number" | "string" | "boolean" | "object" | "null" | "array";
222
- format?: "int32" | "int64" | "float" | "double" | "byte" | "binary" | "date" | "date-time" | "password" | string;
223
- allOf?: (SchemaObject | ReferenceObject)[];
224
- oneOf?: (SchemaObject | ReferenceObject)[];
225
- anyOf?: (SchemaObject | ReferenceObject)[];
226
- not?: SchemaObject | ReferenceObject;
227
- items?: SchemaObject | ReferenceObject;
228
- properties?: {
229
- [propertyName: string]: SchemaObject | ReferenceObject;
230
- };
231
- additionalProperties?: SchemaObject | ReferenceObject | boolean;
232
- description?: string;
233
- default?: any;
234
- title?: string;
235
- multipleOf?: number;
236
- maximum?: number;
237
- exclusiveMaximum?: boolean;
238
- minimum?: number;
239
- exclusiveMinimum?: boolean;
240
- maxLength?: number;
241
- minLength?: number;
242
- pattern?: string;
243
- maxItems?: number;
244
- minItems?: number;
245
- uniqueItems?: boolean;
246
- maxProperties?: number;
247
- minProperties?: number;
248
- enum?: any[];
249
- mediaType: string | undefined;
250
- } | {
251
- mediaType: string | undefined;
252
- required: any;
253
- type: string;
254
- } | null;
255
- getFileTP(requestBody?: any): any;
256
- resolveFileTP(obj: any): any;
257
- getResponseTP(responses?: ResponsesObject): {
258
- mediaType: string;
259
- type: string;
260
- };
261
- getParamsTP(parameters?: (ParameterObject | ReferenceObject)[], path?: string): Record<string, ParameterObject[]>;
262
- private collectRefs;
263
- getInterfaceTP(): {
264
- typeName: string;
265
- type: any;
266
- parent: any;
267
- props: any;
268
- isEnum: any;
269
- }[] | undefined;
270
- private genFileFromTemplate;
271
- private getTemplate;
272
- getProps(schemaObject: SchemaObject): {
273
- name: string;
274
- type: string;
275
- desc: string;
276
- required: boolean;
277
- nullable?: boolean;
278
- discriminator?: import("openapi3-ts").DiscriminatorObject;
279
- readOnly?: boolean;
280
- writeOnly?: boolean;
281
- xml?: import("openapi3-ts").XmlObject;
282
- externalDocs?: import("openapi3-ts").ExternalDocumentationObject;
283
- example?: any;
284
- examples?: any[];
285
- deprecated?: boolean;
286
- format?: "int32" | "int64" | "float" | "double" | "byte" | "binary" | "date" | "date-time" | "password" | string;
287
- allOf?: (SchemaObject | ReferenceObject)[];
288
- oneOf?: (SchemaObject | ReferenceObject)[];
289
- anyOf?: (SchemaObject | ReferenceObject)[];
290
- not?: SchemaObject | ReferenceObject;
291
- items?: SchemaObject | ReferenceObject;
292
- properties?: {
293
- [propertyName: string]: SchemaObject | ReferenceObject;
294
- };
295
- additionalProperties?: SchemaObject | ReferenceObject | boolean;
296
- description?: string;
297
- default?: any;
298
- title?: string;
299
- multipleOf?: number;
300
- maximum?: number;
301
- exclusiveMaximum?: boolean;
302
- minimum?: number;
303
- exclusiveMinimum?: boolean;
304
- maxLength?: number;
305
- minLength?: number;
306
- pattern?: string;
307
- maxItems?: number;
308
- minItems?: number;
309
- uniqueItems?: boolean;
310
- maxProperties?: number;
311
- minProperties?: number;
312
- enum?: any[];
313
- }[];
314
- getType(schemaObject: SchemaObject | undefined, namespace?: string): string;
315
- resolveObject(schemaObject: SchemaObject): any;
316
- resolveArray(schemaObject: SchemaObject): "any[]" | {
317
- type: string;
318
- };
319
- resolveProperties(schemaObject: SchemaObject): {
320
- props: {
321
- name: string;
322
- type: string;
323
- desc: string;
324
- required: boolean;
325
- nullable?: boolean;
326
- discriminator?: import("openapi3-ts").DiscriminatorObject;
327
- readOnly?: boolean;
328
- writeOnly?: boolean;
329
- xml?: import("openapi3-ts").XmlObject;
330
- externalDocs?: import("openapi3-ts").ExternalDocumentationObject;
331
- example?: any;
332
- examples?: any[];
333
- deprecated?: boolean;
334
- format?: "int32" | "int64" | "float" | "double" | "byte" | "binary" | "date" | "date-time" | "password" | string;
335
- allOf?: (SchemaObject | ReferenceObject)[];
336
- oneOf?: (SchemaObject | ReferenceObject)[];
337
- anyOf?: (SchemaObject | ReferenceObject)[];
338
- not?: SchemaObject | ReferenceObject;
339
- items?: SchemaObject | ReferenceObject;
340
- properties?: {
341
- [propertyName: string]: SchemaObject | ReferenceObject;
342
- };
343
- additionalProperties?: SchemaObject | ReferenceObject | boolean;
344
- description?: string;
345
- default?: any;
346
- title?: string;
347
- multipleOf?: number;
348
- maximum?: number;
349
- exclusiveMaximum?: boolean;
350
- minimum?: number;
351
- exclusiveMinimum?: boolean;
352
- maxLength?: number;
353
- minLength?: number;
354
- pattern?: string;
355
- maxItems?: number;
356
- minItems?: number;
357
- uniqueItems?: boolean;
358
- maxProperties?: number;
359
- minProperties?: number;
360
- enum?: any[];
361
- }[][];
362
- };
363
- resolveEnumObject(schemaObject: SchemaObject): {
364
- isEnum: boolean;
365
- type: string | undefined;
366
- };
367
- resolveAllOfObject(schemaObject: SchemaObject): {
368
- props: ({
369
- name: string;
370
- type: string;
371
- desc: string;
372
- required: boolean;
373
- nullable?: boolean;
374
- discriminator?: import("openapi3-ts").DiscriminatorObject;
375
- readOnly?: boolean;
376
- writeOnly?: boolean;
377
- xml?: import("openapi3-ts").XmlObject;
378
- externalDocs?: import("openapi3-ts").ExternalDocumentationObject;
379
- example?: any;
380
- examples?: any[];
381
- deprecated?: boolean;
382
- format?: "int32" | "int64" | "float" | "double" | "byte" | "binary" | "date" | "date-time" | "password" | string;
383
- allOf?: (SchemaObject | ReferenceObject)[];
384
- oneOf?: (SchemaObject | ReferenceObject)[];
385
- anyOf?: (SchemaObject | ReferenceObject)[];
386
- not?: SchemaObject | ReferenceObject;
387
- items?: SchemaObject | ReferenceObject;
388
- properties?: {
389
- [propertyName: string]: SchemaObject | ReferenceObject;
390
- };
391
- additionalProperties?: SchemaObject | ReferenceObject | boolean;
392
- description?: string;
393
- default?: any;
394
- title?: string;
395
- multipleOf?: number;
396
- maximum?: number;
397
- exclusiveMaximum?: boolean;
398
- minimum?: number;
399
- exclusiveMinimum?: boolean;
400
- maxLength?: number;
401
- minLength?: number;
402
- pattern?: string;
403
- maxItems?: number;
404
- minItems?: number;
405
- uniqueItems?: boolean;
406
- maxProperties?: number;
407
- minProperties?: number;
408
- enum?: any[];
409
- }[] | ({
410
- type: string | undefined;
411
- $ref: string;
412
- } | {
413
- type: string | undefined;
414
- nullable?: boolean;
415
- discriminator?: import("openapi3-ts").DiscriminatorObject;
416
- readOnly?: boolean;
417
- writeOnly?: boolean;
418
- xml?: import("openapi3-ts").XmlObject;
419
- externalDocs?: import("openapi3-ts").ExternalDocumentationObject;
420
- example?: any;
421
- examples?: any[];
422
- deprecated?: boolean;
423
- format?: "int32" | "int64" | "float" | "double" | "byte" | "binary" | "date" | "date-time" | "password" | string;
424
- allOf?: (SchemaObject | ReferenceObject)[];
425
- oneOf?: (SchemaObject | ReferenceObject)[];
426
- anyOf?: (SchemaObject | ReferenceObject)[];
427
- not?: SchemaObject | ReferenceObject;
428
- items?: SchemaObject | ReferenceObject;
429
- properties?: {
430
- [propertyName: string]: SchemaObject | ReferenceObject;
431
- };
432
- additionalProperties?: SchemaObject | ReferenceObject | boolean;
433
- description?: string;
434
- default?: any;
435
- title?: string;
436
- multipleOf?: number;
437
- maximum?: number;
438
- exclusiveMaximum?: boolean;
439
- minimum?: number;
440
- exclusiveMinimum?: boolean;
441
- maxLength?: number;
442
- minLength?: number;
443
- pattern?: string;
444
- maxItems?: number;
445
- minItems?: number;
446
- uniqueItems?: boolean;
447
- maxProperties?: number;
448
- minProperties?: number;
449
- required?: string[];
450
- enum?: any[];
451
- })[])[];
452
- };
453
- private genDefaultFunctionName;
454
- private getBasePrefix;
455
- private resolveRefObject;
456
- private getFinalFileName;
457
- private replaceDot;
458
- private resolveFunctionName;
459
- }
460
- export { ServiceGenerator };
package/src/typings.d.ts DELETED
@@ -1,6 +0,0 @@
1
- declare module 'node-fetch';
2
- declare module 'swagger2openapi';
3
- declare module 'reserved-words';
4
- declare module 'tiny-pinyin';
5
- declare module 'number-to-words';
6
- declare module 'memoizee';
package/src/util.d.ts DELETED
@@ -1,35 +0,0 @@
1
- export declare const getAbsolutePath: (filePath: string) => string;
2
- export declare const mkdir: (dir: string) => void;
3
- export declare const prettierFile: (content: string) => Promise<[string, boolean]>;
4
- export declare const writeFile: (folderPath: string, fileName: string, content: string) => Promise<boolean>;
5
- export declare const getTagName: (name: string) => string | undefined;
6
- /**
7
- * 根据当前的数据源类型,对请求回来的 apiInfo 进行格式化
8
- * 如果是 op 数据源,对 tags 以及 path 中的 tags 进行处理
9
- * - before: 前缀(产品集.产品码) + 操作对象(必填)+ 子操作对象(可选)+ 动作(必填)
10
- * - after: 操作对象(必填)+ 子操作对象(可选) ==> 驼峰
11
- */
12
- export declare const formatApiInfo: (apiInfo: Record<string, any>) => any;
13
- type serviceParam = {
14
- title: string;
15
- type: string;
16
- description: string;
17
- default: string;
18
- [key: string]: any;
19
- };
20
- type serviceParams = Record<string, serviceParam>;
21
- /**
22
- * 一方化场景下,由于 onex 会对请求的响应做处理
23
- * 1. 将 Response & Request 中的参数字段会变更为小驼峰写法
24
- * onex 相关代码 : http://gitlab.alipay-inc.com/one-console/sdk/blob/master/src/request.ts#L110
25
- * 2. 另外要注意:
26
- * op 返回的数据,请求参数的类型格式 需要做额外的处理
27
- * - (name) key.n, (type) string ==> key: string []
28
- * - (name) key.m, (type) string ===> key: string []
29
- * - (name) key.key1 , (type) string ==> key: {key1:string}
30
- * - (name) key.n.key1 ,(type) string => key:{ key1 :string}[]
31
- * - (name) key.n.key1.m,(type) string ==> key:{key1: string[]}[]
32
- */
33
- export declare function formatParamsForYFH(params: serviceParams, paramsObject?: serviceParams): serviceParams;
34
- export declare const stripDot: (str: string) => string;
35
- export {};