@orval/core 6.11.0-alpha.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 +28 -0
- package/dist/index.d.ts +1097 -0
- package/dist/index.js +111 -0
- package/package.json +53 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1097 @@
|
|
|
1
|
+
import SwaggerParser from '@apidevtools/swagger-parser';
|
|
2
|
+
import * as openapi3_ts from 'openapi3-ts';
|
|
3
|
+
import { InfoObject, OperationObject, OpenAPIObject, ParameterObject, SchemaObject, ComponentsObject, SchemasObject, PathItemObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject } from 'openapi3-ts';
|
|
4
|
+
import swagger2openapi from 'swagger2openapi';
|
|
5
|
+
import { CompareOperator } from 'compare-versions';
|
|
6
|
+
import debug from 'debug';
|
|
7
|
+
|
|
8
|
+
interface Options {
|
|
9
|
+
output?: string | OutputOptions;
|
|
10
|
+
input?: string | InputOptions;
|
|
11
|
+
hooks?: Partial<HooksOptions>;
|
|
12
|
+
}
|
|
13
|
+
declare type OptionsFn = () => Options | Promise<Options>;
|
|
14
|
+
declare type OptionsExport = Options | Promise<Options> | OptionsFn;
|
|
15
|
+
declare type Config = {
|
|
16
|
+
[project: string]: OptionsExport;
|
|
17
|
+
};
|
|
18
|
+
declare type ConfigFn = () => Config | Promise<Config>;
|
|
19
|
+
declare type ConfigExternal = Config | Promise<Config> | ConfigFn;
|
|
20
|
+
declare type NormizaledConfig = {
|
|
21
|
+
[project: string]: NormalizedOptions;
|
|
22
|
+
};
|
|
23
|
+
interface NormalizedOptions {
|
|
24
|
+
output: NormalizedOutputOptions;
|
|
25
|
+
input: NormalizedInputOptions;
|
|
26
|
+
hooks: NormalizedHookOptions;
|
|
27
|
+
}
|
|
28
|
+
declare type NormalizedOutputOptions = {
|
|
29
|
+
workspace?: string;
|
|
30
|
+
target?: string;
|
|
31
|
+
schemas?: string;
|
|
32
|
+
mode: OutputMode;
|
|
33
|
+
mock: boolean | ClientMSWBuilder;
|
|
34
|
+
override: NormalizedOverrideOutput;
|
|
35
|
+
client: OutputClient | OutputClientFunc;
|
|
36
|
+
clean: boolean | string[];
|
|
37
|
+
prettier: boolean;
|
|
38
|
+
tslint: boolean;
|
|
39
|
+
tsconfig?: Tsconfig;
|
|
40
|
+
packageJson?: PackageJson;
|
|
41
|
+
headers: boolean;
|
|
42
|
+
};
|
|
43
|
+
declare type NormalizedOverrideOutput = {
|
|
44
|
+
title?: (title: string) => string;
|
|
45
|
+
transformer?: OutputTransformer;
|
|
46
|
+
mutator?: NormalizedMutator;
|
|
47
|
+
operations: {
|
|
48
|
+
[key: string]: NormalizedOperationOptions;
|
|
49
|
+
};
|
|
50
|
+
tags: {
|
|
51
|
+
[key: string]: NormalizedOperationOptions;
|
|
52
|
+
};
|
|
53
|
+
mock?: {
|
|
54
|
+
arrayMin?: number;
|
|
55
|
+
arrayMax?: number;
|
|
56
|
+
properties?: MockProperties;
|
|
57
|
+
format?: {
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
required?: boolean;
|
|
61
|
+
baseUrl?: string;
|
|
62
|
+
delay?: number;
|
|
63
|
+
};
|
|
64
|
+
contentType?: OverrideOutputContentType;
|
|
65
|
+
header: false | ((info: InfoObject) => string[] | string);
|
|
66
|
+
formData: boolean | NormalizedMutator;
|
|
67
|
+
formUrlEncoded: boolean | NormalizedMutator;
|
|
68
|
+
components: {
|
|
69
|
+
schemas: {
|
|
70
|
+
suffix: string;
|
|
71
|
+
};
|
|
72
|
+
responses: {
|
|
73
|
+
suffix: string;
|
|
74
|
+
};
|
|
75
|
+
parameters: {
|
|
76
|
+
suffix: string;
|
|
77
|
+
};
|
|
78
|
+
requestBodies: {
|
|
79
|
+
suffix: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
query: QueryOptions;
|
|
83
|
+
angular: Required<AngularOptions>;
|
|
84
|
+
swr: {
|
|
85
|
+
options?: any;
|
|
86
|
+
};
|
|
87
|
+
operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
88
|
+
requestOptions: Record<string, any> | boolean;
|
|
89
|
+
useDates?: boolean;
|
|
90
|
+
useTypeOverInterfaces?: boolean;
|
|
91
|
+
useDeprecatedOperations?: boolean;
|
|
92
|
+
};
|
|
93
|
+
declare type NormalizedMutator = {
|
|
94
|
+
path: string;
|
|
95
|
+
name?: string;
|
|
96
|
+
default: boolean;
|
|
97
|
+
alias?: Record<string, string>;
|
|
98
|
+
};
|
|
99
|
+
declare type NormalizedOperationOptions = {
|
|
100
|
+
transformer?: OutputTransformer;
|
|
101
|
+
mutator?: NormalizedMutator;
|
|
102
|
+
mock?: {
|
|
103
|
+
data?: MockProperties;
|
|
104
|
+
properties?: MockProperties;
|
|
105
|
+
};
|
|
106
|
+
contentType?: OverrideOutputContentType;
|
|
107
|
+
query?: QueryOptions;
|
|
108
|
+
angular?: Required<AngularOptions>;
|
|
109
|
+
swr?: {
|
|
110
|
+
options?: any;
|
|
111
|
+
};
|
|
112
|
+
operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
113
|
+
formData?: boolean | NormalizedMutator;
|
|
114
|
+
formUrlEncoded?: boolean | NormalizedMutator;
|
|
115
|
+
requestOptions?: object | boolean;
|
|
116
|
+
};
|
|
117
|
+
declare type NormalizedInputOptions = {
|
|
118
|
+
target: string | Record<string, unknown> | OpenAPIObject;
|
|
119
|
+
validation: boolean;
|
|
120
|
+
override: OverrideInput;
|
|
121
|
+
converterOptions: swagger2openapi.Options;
|
|
122
|
+
parserOptions: SwaggerParserOptions;
|
|
123
|
+
};
|
|
124
|
+
declare type OutputClientFunc = (clients: GeneratorClients) => ClientGeneratorsBuilder;
|
|
125
|
+
declare type OutputOptions = {
|
|
126
|
+
workspace?: string;
|
|
127
|
+
target?: string;
|
|
128
|
+
schemas?: string;
|
|
129
|
+
mode?: OutputMode;
|
|
130
|
+
mock?: boolean | ClientMSWBuilder;
|
|
131
|
+
override?: OverrideOutput;
|
|
132
|
+
client?: OutputClient | OutputClientFunc;
|
|
133
|
+
clean?: boolean | string[];
|
|
134
|
+
prettier?: boolean;
|
|
135
|
+
tslint?: boolean;
|
|
136
|
+
tsconfig?: string | Tsconfig;
|
|
137
|
+
packageJson?: string;
|
|
138
|
+
headers?: boolean;
|
|
139
|
+
};
|
|
140
|
+
declare type SwaggerParserOptions = Omit<SwaggerParser.Options, 'validate'> & {
|
|
141
|
+
validate?: boolean;
|
|
142
|
+
};
|
|
143
|
+
declare type InputOptions = {
|
|
144
|
+
target: string | Record<string, unknown> | OpenAPIObject;
|
|
145
|
+
validation?: boolean;
|
|
146
|
+
override?: OverrideInput;
|
|
147
|
+
converterOptions?: swagger2openapi.Options;
|
|
148
|
+
parserOptions?: SwaggerParserOptions;
|
|
149
|
+
};
|
|
150
|
+
declare type OutputClient = 'axios' | 'axios-functions' | 'angular' | 'react-query' | 'svelte-query' | 'vue-query' | 'swr';
|
|
151
|
+
declare const OutputClient: {
|
|
152
|
+
ANGULAR: OutputClient;
|
|
153
|
+
AXIOS: OutputClient;
|
|
154
|
+
AXIOS_FUNCTIONS: OutputClient;
|
|
155
|
+
REACT_QUERY: OutputClient;
|
|
156
|
+
SVELTE_QUERY: OutputClient;
|
|
157
|
+
VUE_QUERY: OutputClient;
|
|
158
|
+
};
|
|
159
|
+
declare type OutputMode = 'single' | 'split' | 'tags' | 'tags-split';
|
|
160
|
+
declare const OutputMode: {
|
|
161
|
+
SINGLE: OutputMode;
|
|
162
|
+
SPLIT: OutputMode;
|
|
163
|
+
TAGS: OutputMode;
|
|
164
|
+
TAGS_SPLIT: OutputMode;
|
|
165
|
+
};
|
|
166
|
+
declare type MockOptions = {
|
|
167
|
+
arrayMin?: number;
|
|
168
|
+
arrayMax?: number;
|
|
169
|
+
required?: boolean;
|
|
170
|
+
properties?: Record<string, string>;
|
|
171
|
+
operations?: Record<string, {
|
|
172
|
+
properties: Record<string, string>;
|
|
173
|
+
}>;
|
|
174
|
+
format?: Record<string, string>;
|
|
175
|
+
tags?: Record<string, {
|
|
176
|
+
properties: Record<string, string>;
|
|
177
|
+
}>;
|
|
178
|
+
};
|
|
179
|
+
declare type MockProperties = {
|
|
180
|
+
[key: string]: unknown;
|
|
181
|
+
} | ((specs: OpenAPIObject) => {
|
|
182
|
+
[key: string]: unknown;
|
|
183
|
+
});
|
|
184
|
+
declare type OutputTransformerFn = (verb: GeneratorVerbOptions) => GeneratorVerbOptions;
|
|
185
|
+
declare type OutputTransformer = string | OutputTransformerFn;
|
|
186
|
+
declare type MutatorObject = {
|
|
187
|
+
path: string;
|
|
188
|
+
name?: string;
|
|
189
|
+
default?: boolean;
|
|
190
|
+
alias?: Record<string, string>;
|
|
191
|
+
};
|
|
192
|
+
declare type Mutator = string | MutatorObject;
|
|
193
|
+
declare type OverrideOutput = {
|
|
194
|
+
title?: (title: string) => string;
|
|
195
|
+
transformer?: OutputTransformer;
|
|
196
|
+
mutator?: Mutator;
|
|
197
|
+
operations?: {
|
|
198
|
+
[key: string]: OperationOptions;
|
|
199
|
+
};
|
|
200
|
+
tags?: {
|
|
201
|
+
[key: string]: OperationOptions;
|
|
202
|
+
};
|
|
203
|
+
mock?: {
|
|
204
|
+
arrayMin?: number;
|
|
205
|
+
arrayMax?: number;
|
|
206
|
+
properties?: MockProperties;
|
|
207
|
+
format?: {
|
|
208
|
+
[key: string]: unknown;
|
|
209
|
+
};
|
|
210
|
+
required?: boolean;
|
|
211
|
+
baseUrl?: string;
|
|
212
|
+
delay?: number;
|
|
213
|
+
};
|
|
214
|
+
contentType?: OverrideOutputContentType;
|
|
215
|
+
header?: boolean | ((info: InfoObject) => string[] | string);
|
|
216
|
+
formData?: boolean | Mutator;
|
|
217
|
+
formUrlEncoded?: boolean | Mutator;
|
|
218
|
+
components?: {
|
|
219
|
+
schemas?: {
|
|
220
|
+
suffix?: string;
|
|
221
|
+
};
|
|
222
|
+
responses?: {
|
|
223
|
+
suffix?: string;
|
|
224
|
+
};
|
|
225
|
+
parameters?: {
|
|
226
|
+
suffix?: string;
|
|
227
|
+
};
|
|
228
|
+
requestBodies?: {
|
|
229
|
+
suffix?: string;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
query?: QueryOptions;
|
|
233
|
+
swr?: {
|
|
234
|
+
options?: any;
|
|
235
|
+
};
|
|
236
|
+
angular?: AngularOptions;
|
|
237
|
+
operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
238
|
+
requestOptions?: Record<string, any> | boolean;
|
|
239
|
+
useDates?: boolean;
|
|
240
|
+
useTypeOverInterfaces?: boolean;
|
|
241
|
+
useDeprecatedOperations?: boolean;
|
|
242
|
+
};
|
|
243
|
+
declare type OverrideOutputContentType = {
|
|
244
|
+
include?: string[];
|
|
245
|
+
exclude?: string[];
|
|
246
|
+
};
|
|
247
|
+
declare type QueryOptions = {
|
|
248
|
+
useQuery?: boolean;
|
|
249
|
+
useInfinite?: boolean;
|
|
250
|
+
useInfiniteQueryParam?: string;
|
|
251
|
+
options?: any;
|
|
252
|
+
signal?: boolean;
|
|
253
|
+
};
|
|
254
|
+
declare type AngularOptions = {
|
|
255
|
+
provideIn?: 'root' | 'any' | boolean;
|
|
256
|
+
};
|
|
257
|
+
declare type InputTransformerFn = (spec: OpenAPIObject) => OpenAPIObject;
|
|
258
|
+
declare type InputTransformer = string | InputTransformerFn;
|
|
259
|
+
declare type OverrideInput = {
|
|
260
|
+
transformer?: InputTransformer;
|
|
261
|
+
};
|
|
262
|
+
declare type OperationOptions = {
|
|
263
|
+
transformer?: OutputTransformer;
|
|
264
|
+
mutator?: Mutator;
|
|
265
|
+
mock?: {
|
|
266
|
+
data?: MockProperties;
|
|
267
|
+
properties?: MockProperties;
|
|
268
|
+
};
|
|
269
|
+
query?: QueryOptions;
|
|
270
|
+
angular?: Required<AngularOptions>;
|
|
271
|
+
swr?: {
|
|
272
|
+
options?: any;
|
|
273
|
+
};
|
|
274
|
+
operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
275
|
+
formData?: boolean | Mutator;
|
|
276
|
+
formUrlEncoded?: boolean | Mutator;
|
|
277
|
+
requestOptions?: object | boolean;
|
|
278
|
+
};
|
|
279
|
+
declare type Hook = 'afterAllFilesWrite';
|
|
280
|
+
declare type HookFunction = (...args: any[]) => void | Promise<void>;
|
|
281
|
+
declare type HookCommand = string | HookFunction | (string | HookFunction)[];
|
|
282
|
+
declare type NormalizedHookCommand = HookCommand[];
|
|
283
|
+
declare type HooksOptions<T = HookCommand | NormalizedHookCommand> = Partial<Record<Hook, T>>;
|
|
284
|
+
declare type NormalizedHookOptions = HooksOptions<NormalizedHookCommand>;
|
|
285
|
+
declare type Verbs = 'post' | 'put' | 'get' | 'patch' | 'delete' | 'head';
|
|
286
|
+
declare const Verbs: {
|
|
287
|
+
POST: Verbs;
|
|
288
|
+
PUT: Verbs;
|
|
289
|
+
GET: Verbs;
|
|
290
|
+
PATCH: Verbs;
|
|
291
|
+
DELETE: Verbs;
|
|
292
|
+
HEAD: Verbs;
|
|
293
|
+
};
|
|
294
|
+
declare type ImportOpenApi = {
|
|
295
|
+
data: Record<string, unknown | OpenAPIObject>;
|
|
296
|
+
input: InputOptions;
|
|
297
|
+
output: NormalizedOutputOptions;
|
|
298
|
+
target: string;
|
|
299
|
+
workspace: string;
|
|
300
|
+
};
|
|
301
|
+
interface ContextSpecs {
|
|
302
|
+
specKey: string;
|
|
303
|
+
target: string;
|
|
304
|
+
workspace: string;
|
|
305
|
+
tslint: boolean;
|
|
306
|
+
specs: Record<string, OpenAPIObject>;
|
|
307
|
+
override: NormalizedOverrideOutput;
|
|
308
|
+
tsconfig?: Tsconfig;
|
|
309
|
+
packageJson?: PackageJson;
|
|
310
|
+
}
|
|
311
|
+
interface GlobalOptions {
|
|
312
|
+
projectName?: string;
|
|
313
|
+
watch?: boolean | string | (string | boolean)[];
|
|
314
|
+
clean?: boolean | string[];
|
|
315
|
+
prettier?: boolean;
|
|
316
|
+
tslint?: boolean;
|
|
317
|
+
mock?: boolean;
|
|
318
|
+
client?: OutputClient;
|
|
319
|
+
mode?: OutputMode;
|
|
320
|
+
tsconfig?: string | Tsconfig;
|
|
321
|
+
packageJson?: string;
|
|
322
|
+
input?: string;
|
|
323
|
+
output?: string;
|
|
324
|
+
}
|
|
325
|
+
interface Tsconfig {
|
|
326
|
+
baseUrl?: string;
|
|
327
|
+
compilerOptions?: {
|
|
328
|
+
esModuleInterop?: boolean;
|
|
329
|
+
allowSyntheticDefaultImports?: boolean;
|
|
330
|
+
exactOptionalPropertyTypes?: boolean;
|
|
331
|
+
paths?: Record<string, string[]>;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
interface PackageJson {
|
|
335
|
+
dependencies?: Record<string, string>;
|
|
336
|
+
devDependencies?: Record<string, string>;
|
|
337
|
+
}
|
|
338
|
+
declare type GeneratorSchema = {
|
|
339
|
+
name: string;
|
|
340
|
+
model: string;
|
|
341
|
+
imports: GeneratorImport[];
|
|
342
|
+
};
|
|
343
|
+
declare type GeneratorImport = {
|
|
344
|
+
name: string;
|
|
345
|
+
schemaName?: string;
|
|
346
|
+
alias?: string;
|
|
347
|
+
specKey?: string;
|
|
348
|
+
default?: boolean;
|
|
349
|
+
values?: boolean;
|
|
350
|
+
syntheticDefaultImport?: boolean;
|
|
351
|
+
};
|
|
352
|
+
declare type GeneratorDependency = {
|
|
353
|
+
exports: GeneratorImport[];
|
|
354
|
+
dependency: string;
|
|
355
|
+
};
|
|
356
|
+
declare type GeneratorApiResponse = {
|
|
357
|
+
operations: GeneratorOperations;
|
|
358
|
+
schemas: GeneratorSchema[];
|
|
359
|
+
};
|
|
360
|
+
declare type GeneratorOperations = {
|
|
361
|
+
[operationId: string]: GeneratorOperation;
|
|
362
|
+
};
|
|
363
|
+
declare type GeneratorTarget = {
|
|
364
|
+
imports: GeneratorImport[];
|
|
365
|
+
implementation: string;
|
|
366
|
+
implementationMSW: string;
|
|
367
|
+
importsMSW: GeneratorImport[];
|
|
368
|
+
mutators?: GeneratorMutator[];
|
|
369
|
+
formData?: GeneratorMutator[];
|
|
370
|
+
formUrlEncoded?: GeneratorMutator[];
|
|
371
|
+
};
|
|
372
|
+
declare type GeneratorTargetFull = {
|
|
373
|
+
imports: GeneratorImport[];
|
|
374
|
+
implementation: string;
|
|
375
|
+
implementationMSW: {
|
|
376
|
+
function: string;
|
|
377
|
+
handler: string;
|
|
378
|
+
};
|
|
379
|
+
importsMSW: GeneratorImport[];
|
|
380
|
+
mutators?: GeneratorMutator[];
|
|
381
|
+
formData?: GeneratorMutator[];
|
|
382
|
+
formUrlEncoded?: GeneratorMutator[];
|
|
383
|
+
};
|
|
384
|
+
declare type GeneratorOperation = {
|
|
385
|
+
imports: GeneratorImport[];
|
|
386
|
+
implementation: string;
|
|
387
|
+
implementationMSW: {
|
|
388
|
+
function: string;
|
|
389
|
+
handler: string;
|
|
390
|
+
};
|
|
391
|
+
importsMSW: GeneratorImport[];
|
|
392
|
+
tags: string[];
|
|
393
|
+
mutator?: GeneratorMutator;
|
|
394
|
+
formData?: GeneratorMutator;
|
|
395
|
+
formUrlEncoded?: GeneratorMutator;
|
|
396
|
+
operationName: string;
|
|
397
|
+
types?: {
|
|
398
|
+
result: (title?: string) => string;
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
declare type GeneratorVerbOptions = {
|
|
402
|
+
verb: Verbs;
|
|
403
|
+
summary?: string;
|
|
404
|
+
doc: string;
|
|
405
|
+
tags: string[];
|
|
406
|
+
operationId: string;
|
|
407
|
+
operationName: string;
|
|
408
|
+
response: GetterResponse;
|
|
409
|
+
body: GetterBody;
|
|
410
|
+
headers?: GetterQueryParam;
|
|
411
|
+
queryParams?: GetterQueryParam;
|
|
412
|
+
params: GetterParams;
|
|
413
|
+
props: GetterProps;
|
|
414
|
+
mutator?: GeneratorMutator;
|
|
415
|
+
formData?: GeneratorMutator;
|
|
416
|
+
formUrlEncoded?: GeneratorMutator;
|
|
417
|
+
override: NormalizedOverrideOutput;
|
|
418
|
+
deprecated?: boolean;
|
|
419
|
+
};
|
|
420
|
+
declare type GeneratorVerbsOptions = GeneratorVerbOptions[];
|
|
421
|
+
declare type GeneratorOptions = {
|
|
422
|
+
route: string;
|
|
423
|
+
pathRoute: string;
|
|
424
|
+
override: NormalizedOverrideOutput;
|
|
425
|
+
context: ContextSpecs;
|
|
426
|
+
mock: boolean;
|
|
427
|
+
};
|
|
428
|
+
declare type GeneratorClient = {
|
|
429
|
+
implementation: string;
|
|
430
|
+
imports: GeneratorImport[];
|
|
431
|
+
types?: {
|
|
432
|
+
result: (title?: string) => string;
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
declare type GeneratorMutatorParsingInfo = {
|
|
436
|
+
numberOfParams: number;
|
|
437
|
+
returnNumberOfParams?: number;
|
|
438
|
+
};
|
|
439
|
+
declare type GeneratorMutator = {
|
|
440
|
+
name: string;
|
|
441
|
+
path: string;
|
|
442
|
+
default: boolean;
|
|
443
|
+
hasErrorType: boolean;
|
|
444
|
+
errorTypeName: string;
|
|
445
|
+
hasSecondArg: boolean;
|
|
446
|
+
hasThirdArg: boolean;
|
|
447
|
+
isHook: boolean;
|
|
448
|
+
bodyTypeName?: string;
|
|
449
|
+
};
|
|
450
|
+
declare type ClientBuilder = (verbOptions: GeneratorVerbOptions, options: GeneratorOptions, outputClient: OutputClient | OutputClientFunc) => GeneratorClient;
|
|
451
|
+
declare type ClientHeaderBuilder = (params: {
|
|
452
|
+
title: string;
|
|
453
|
+
isRequestOptions: boolean;
|
|
454
|
+
isMutator: boolean;
|
|
455
|
+
noFunction?: boolean;
|
|
456
|
+
isGlobalMutator: boolean;
|
|
457
|
+
provideIn: boolean | 'root' | 'any';
|
|
458
|
+
hasAwaitedType: boolean;
|
|
459
|
+
}) => string;
|
|
460
|
+
declare type ClientFooterBuilder = (params: {
|
|
461
|
+
noFunction?: boolean | undefined;
|
|
462
|
+
operationNames: string[];
|
|
463
|
+
title?: string;
|
|
464
|
+
hasAwaitedType: boolean;
|
|
465
|
+
hasMutator: boolean;
|
|
466
|
+
}) => string;
|
|
467
|
+
declare type ClientTitleBuilder = (title: string) => string;
|
|
468
|
+
declare type ClientDependenciesBuilder = (hasGlobalMutator: boolean, packageJson?: PackageJson) => GeneratorDependency[];
|
|
469
|
+
declare type ClientMSWBuilder = (verbOptions: GeneratorVerbOptions, generatorOptions: GeneratorOptions) => {
|
|
470
|
+
imports: string[];
|
|
471
|
+
implementation: string;
|
|
472
|
+
};
|
|
473
|
+
interface ClientGeneratorsBuilder {
|
|
474
|
+
client: ClientBuilder;
|
|
475
|
+
header: ClientHeaderBuilder;
|
|
476
|
+
dependencies: ClientDependenciesBuilder;
|
|
477
|
+
footer: ClientFooterBuilder;
|
|
478
|
+
title: ClientTitleBuilder;
|
|
479
|
+
}
|
|
480
|
+
declare type GeneratorClients = Record<OutputClient, ClientGeneratorsBuilder>;
|
|
481
|
+
declare type GetterResponse = {
|
|
482
|
+
imports: GeneratorImport[];
|
|
483
|
+
definition: {
|
|
484
|
+
success: string;
|
|
485
|
+
errors: string;
|
|
486
|
+
};
|
|
487
|
+
isBlob: boolean;
|
|
488
|
+
types: {
|
|
489
|
+
success: ResReqTypesValue[];
|
|
490
|
+
errors: ResReqTypesValue[];
|
|
491
|
+
};
|
|
492
|
+
contentTypes: string[];
|
|
493
|
+
schemas: GeneratorSchema[];
|
|
494
|
+
};
|
|
495
|
+
declare type GetterBody = {
|
|
496
|
+
imports: GeneratorImport[];
|
|
497
|
+
definition: string;
|
|
498
|
+
implementation: string;
|
|
499
|
+
schemas: GeneratorSchema[];
|
|
500
|
+
formData?: string;
|
|
501
|
+
formUrlEncoded?: string;
|
|
502
|
+
contentType: string;
|
|
503
|
+
};
|
|
504
|
+
declare type GetterParameters = {
|
|
505
|
+
query: {
|
|
506
|
+
parameter: ParameterObject;
|
|
507
|
+
imports: GeneratorImport[];
|
|
508
|
+
}[];
|
|
509
|
+
path: {
|
|
510
|
+
parameter: ParameterObject;
|
|
511
|
+
imports: GeneratorImport[];
|
|
512
|
+
}[];
|
|
513
|
+
header: {
|
|
514
|
+
parameter: ParameterObject;
|
|
515
|
+
imports: GeneratorImport[];
|
|
516
|
+
}[];
|
|
517
|
+
};
|
|
518
|
+
declare type GetterParam = {
|
|
519
|
+
name: string;
|
|
520
|
+
definition: string;
|
|
521
|
+
implementation: string;
|
|
522
|
+
default: boolean;
|
|
523
|
+
required: boolean;
|
|
524
|
+
imports: GeneratorImport[];
|
|
525
|
+
};
|
|
526
|
+
declare type GetterParams = GetterParam[];
|
|
527
|
+
declare type GetterQueryParam = {
|
|
528
|
+
schema: GeneratorSchema;
|
|
529
|
+
deps: GeneratorSchema[];
|
|
530
|
+
isOptional: boolean;
|
|
531
|
+
};
|
|
532
|
+
declare type GetterPropType = 'param' | 'body' | 'queryParam' | 'header';
|
|
533
|
+
declare const GetterPropType: {
|
|
534
|
+
PARAM: GetterPropType;
|
|
535
|
+
BODY: GetterPropType;
|
|
536
|
+
QUERY_PARAM: GetterPropType;
|
|
537
|
+
HEADER: GetterPropType;
|
|
538
|
+
};
|
|
539
|
+
declare type GetterProp = {
|
|
540
|
+
name: string;
|
|
541
|
+
definition: string;
|
|
542
|
+
implementation: string;
|
|
543
|
+
default: boolean;
|
|
544
|
+
required: boolean;
|
|
545
|
+
type: GetterPropType;
|
|
546
|
+
};
|
|
547
|
+
declare type GetterProps = GetterProp[];
|
|
548
|
+
declare type SchemaType = 'integer' | 'number' | 'string' | 'boolean' | 'object' | 'null' | 'array' | 'enum' | 'unknown';
|
|
549
|
+
declare type ResolverValue = {
|
|
550
|
+
value: string;
|
|
551
|
+
isEnum: boolean;
|
|
552
|
+
type: SchemaType;
|
|
553
|
+
imports: GeneratorImport[];
|
|
554
|
+
schemas: GeneratorSchema[];
|
|
555
|
+
originalSchema?: SchemaObject;
|
|
556
|
+
isRef: boolean;
|
|
557
|
+
};
|
|
558
|
+
declare type ResReqTypesValue = ResolverValue & {
|
|
559
|
+
formData?: string;
|
|
560
|
+
formUrlEncoded?: string;
|
|
561
|
+
isRef?: boolean;
|
|
562
|
+
key: string;
|
|
563
|
+
contentType: string;
|
|
564
|
+
};
|
|
565
|
+
declare type WriteSpecsBuilder = {
|
|
566
|
+
operations: GeneratorOperations;
|
|
567
|
+
schemas: Record<string, GeneratorSchema[]>;
|
|
568
|
+
title: GeneratorClientTitle;
|
|
569
|
+
header: GeneratorClientHeader;
|
|
570
|
+
footer: GeneratorClientFooter;
|
|
571
|
+
imports: GeneratorClientImports;
|
|
572
|
+
importsMock: GenerateMockImports;
|
|
573
|
+
info: InfoObject;
|
|
574
|
+
target: string;
|
|
575
|
+
};
|
|
576
|
+
declare type WriteModeProps = {
|
|
577
|
+
builder: WriteSpecsBuilder;
|
|
578
|
+
output: NormalizedOutputOptions;
|
|
579
|
+
workspace: string;
|
|
580
|
+
specsName: Record<string, string>;
|
|
581
|
+
header: string;
|
|
582
|
+
};
|
|
583
|
+
declare type GeneratorApiOperations = {
|
|
584
|
+
operations: GeneratorOperations;
|
|
585
|
+
schemas: GeneratorSchema[];
|
|
586
|
+
};
|
|
587
|
+
declare type GeneratorClientExtra = {
|
|
588
|
+
implementation: string;
|
|
589
|
+
implementationMSW: string;
|
|
590
|
+
};
|
|
591
|
+
declare type GeneratorClientTitle = (data: {
|
|
592
|
+
outputClient?: OutputClient | OutputClientFunc;
|
|
593
|
+
title: string;
|
|
594
|
+
customTitleFunc?: (title: string) => string;
|
|
595
|
+
}) => GeneratorClientExtra;
|
|
596
|
+
declare type GeneratorClientHeader = (data: {
|
|
597
|
+
outputClient?: OutputClient | OutputClientFunc;
|
|
598
|
+
isRequestOptions: boolean;
|
|
599
|
+
isMutator: boolean;
|
|
600
|
+
isGlobalMutator: boolean;
|
|
601
|
+
provideIn: boolean | 'root' | 'any';
|
|
602
|
+
hasAwaitedType: boolean;
|
|
603
|
+
titles: GeneratorClientExtra;
|
|
604
|
+
}) => GeneratorClientExtra;
|
|
605
|
+
declare type GeneratorClientFooter = (data: {
|
|
606
|
+
outputClient: OutputClient | OutputClientFunc;
|
|
607
|
+
operationNames: string[];
|
|
608
|
+
hasMutator: boolean;
|
|
609
|
+
hasAwaitedType: boolean;
|
|
610
|
+
titles: GeneratorClientExtra;
|
|
611
|
+
}) => GeneratorClientExtra;
|
|
612
|
+
declare type GeneratorClientImports = (data: {
|
|
613
|
+
client: OutputClient | OutputClientFunc;
|
|
614
|
+
implementation: string;
|
|
615
|
+
imports: {
|
|
616
|
+
exports: GeneratorImport[];
|
|
617
|
+
dependency: string;
|
|
618
|
+
}[];
|
|
619
|
+
specsName: Record<string, string>;
|
|
620
|
+
hasSchemaDir: boolean;
|
|
621
|
+
isAllowSyntheticDefaultImports: boolean;
|
|
622
|
+
hasGlobalMutator: boolean;
|
|
623
|
+
packageJson?: PackageJson;
|
|
624
|
+
}) => string;
|
|
625
|
+
declare type GenerateMockImports = (data: {
|
|
626
|
+
implementation: string;
|
|
627
|
+
imports: {
|
|
628
|
+
exports: GeneratorImport[];
|
|
629
|
+
dependency: string;
|
|
630
|
+
}[];
|
|
631
|
+
specsName: Record<string, string>;
|
|
632
|
+
hasSchemaDir: boolean;
|
|
633
|
+
isAllowSyntheticDefaultImports: boolean;
|
|
634
|
+
}) => string;
|
|
635
|
+
declare type GeneratorApiBuilder = GeneratorApiOperations & {
|
|
636
|
+
title: GeneratorClientTitle;
|
|
637
|
+
header: GeneratorClientHeader;
|
|
638
|
+
footer: GeneratorClientFooter;
|
|
639
|
+
imports: GeneratorClientImports;
|
|
640
|
+
importsMock: GenerateMockImports;
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
declare const generalJSTypes: string[];
|
|
644
|
+
declare const generalJSTypesWithArray: string[];
|
|
645
|
+
declare const VERBS_WITH_BODY: Verbs[];
|
|
646
|
+
declare const URL_REGEX: RegExp;
|
|
647
|
+
|
|
648
|
+
declare const generateComponentDefinition: (responses: ComponentsObject['responses'] | ComponentsObject['requestBodies'], context: ContextSpecs, suffix: string) => GeneratorSchema[];
|
|
649
|
+
|
|
650
|
+
declare const generateImports: ({ imports, target, isRootKey, specsName, }: {
|
|
651
|
+
imports: GeneratorImport[];
|
|
652
|
+
target: string;
|
|
653
|
+
isRootKey: boolean;
|
|
654
|
+
specsName: Record<string, string>;
|
|
655
|
+
}) => string;
|
|
656
|
+
declare const generateMutatorImports: ({ mutators, implementation, oneMore, }: {
|
|
657
|
+
mutators: GeneratorMutator[];
|
|
658
|
+
implementation?: string | undefined;
|
|
659
|
+
oneMore?: boolean | undefined;
|
|
660
|
+
}) => string;
|
|
661
|
+
declare const addDependency: ({ implementation, exports, dependency, specsName, hasSchemaDir, isAllowSyntheticDefaultImports, }: {
|
|
662
|
+
implementation: string;
|
|
663
|
+
exports: GeneratorImport[];
|
|
664
|
+
dependency: string;
|
|
665
|
+
specsName: Record<string, string>;
|
|
666
|
+
hasSchemaDir: boolean;
|
|
667
|
+
isAllowSyntheticDefaultImports: boolean;
|
|
668
|
+
}) => string | undefined;
|
|
669
|
+
declare const generateDependencyImports: (implementation: string, imports: {
|
|
670
|
+
exports: GeneratorImport[];
|
|
671
|
+
dependency: string;
|
|
672
|
+
}[], specsName: Record<string, string>, hasSchemaDir: boolean, isAllowSyntheticDefaultImports: boolean) => string;
|
|
673
|
+
declare const generateVerbImports: ({ response, body, queryParams, headers, params, }: GeneratorVerbOptions) => GeneratorImport[];
|
|
674
|
+
|
|
675
|
+
declare const generateModelInline: (acc: string, model: string) => string;
|
|
676
|
+
declare const generateModelsInline: (obj: Record<string, GeneratorSchema[]>) => string;
|
|
677
|
+
|
|
678
|
+
declare const BODY_TYPE_NAME = "BodyType";
|
|
679
|
+
declare const generateMutator: ({ output, mutator, name, workspace, tsconfig, }: {
|
|
680
|
+
output?: string | undefined;
|
|
681
|
+
mutator?: NormalizedMutator | undefined;
|
|
682
|
+
name: string;
|
|
683
|
+
workspace: string;
|
|
684
|
+
tsconfig?: Tsconfig | undefined;
|
|
685
|
+
}) => Promise<GeneratorMutator | undefined>;
|
|
686
|
+
|
|
687
|
+
declare const generateBodyOptions: (body: GetterBody, isFormData: boolean, isFormUrlEncoded: boolean) => string;
|
|
688
|
+
declare const generateAxiosOptions: ({ response, isExactOptionalPropertyTypes, queryParams, headers, requestOptions, hasSignal, }: {
|
|
689
|
+
response: GetterResponse;
|
|
690
|
+
isExactOptionalPropertyTypes: boolean;
|
|
691
|
+
queryParams?: GeneratorSchema | undefined;
|
|
692
|
+
headers?: GeneratorSchema | undefined;
|
|
693
|
+
requestOptions?: boolean | object | undefined;
|
|
694
|
+
hasSignal: boolean;
|
|
695
|
+
}) => string;
|
|
696
|
+
declare const generateOptions: ({ route, body, headers, queryParams, response, verb, requestOptions, isFormData, isFormUrlEncoded, isAngular, isExactOptionalPropertyTypes, hasSignal, }: {
|
|
697
|
+
route: string;
|
|
698
|
+
body: GetterBody;
|
|
699
|
+
headers?: GetterQueryParam | undefined;
|
|
700
|
+
queryParams?: GetterQueryParam | undefined;
|
|
701
|
+
response: GetterResponse;
|
|
702
|
+
verb: Verbs;
|
|
703
|
+
requestOptions?: boolean | object | undefined;
|
|
704
|
+
isFormData: boolean;
|
|
705
|
+
isFormUrlEncoded: boolean;
|
|
706
|
+
isAngular?: boolean | undefined;
|
|
707
|
+
isExactOptionalPropertyTypes: boolean;
|
|
708
|
+
hasSignal: boolean;
|
|
709
|
+
}) => string;
|
|
710
|
+
declare const generateBodyMutatorConfig: (body: GetterBody, isFormData: boolean, isFormUrlEncoded: boolean) => string;
|
|
711
|
+
declare const generateQueryParamsAxiosConfig: (response: GetterResponse, queryParams?: GetterQueryParam) => string;
|
|
712
|
+
declare const generateMutatorConfig: ({ route, body, headers, queryParams, response, verb, isFormData, isFormUrlEncoded, isBodyVerb, hasSignal, isExactOptionalPropertyTypes, }: {
|
|
713
|
+
route: string;
|
|
714
|
+
body: GetterBody;
|
|
715
|
+
headers?: GetterQueryParam | undefined;
|
|
716
|
+
queryParams?: GetterQueryParam | undefined;
|
|
717
|
+
response: GetterResponse;
|
|
718
|
+
verb: Verbs;
|
|
719
|
+
isFormData: boolean;
|
|
720
|
+
isFormUrlEncoded: boolean;
|
|
721
|
+
isBodyVerb: boolean;
|
|
722
|
+
hasSignal: boolean;
|
|
723
|
+
isExactOptionalPropertyTypes: boolean;
|
|
724
|
+
}) => string;
|
|
725
|
+
declare const generateMutatorRequestOptions: (requestOptions: boolean | object | undefined, hasSecondArgument: boolean) => string | undefined;
|
|
726
|
+
declare const generateFormDataAndUrlEncodedFunction: ({ body, formData, formUrlEncoded, isFormData, isFormUrlEncoded, }: {
|
|
727
|
+
body: GetterBody;
|
|
728
|
+
formData?: GeneratorMutator | undefined;
|
|
729
|
+
formUrlEncoded?: GeneratorMutator | undefined;
|
|
730
|
+
isFormData: boolean;
|
|
731
|
+
isFormUrlEncoded: boolean;
|
|
732
|
+
}) => string;
|
|
733
|
+
|
|
734
|
+
declare const generateParameterDefinition: (parameters: ComponentsObject['parameters'], context: ContextSpecs, suffix: string) => GeneratorSchema[];
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Extract all types from #/components/schemas
|
|
738
|
+
*
|
|
739
|
+
* @param schemas
|
|
740
|
+
*/
|
|
741
|
+
declare const generateSchemasDefinition: (schemas: SchemasObject | undefined, context: ContextSpecs, suffix: string) => GeneratorSchema[];
|
|
742
|
+
|
|
743
|
+
declare const generateVerbsOptions: ({ verbs, output, route, context, }: {
|
|
744
|
+
verbs: PathItemObject;
|
|
745
|
+
output: NormalizedOutputOptions;
|
|
746
|
+
route: string;
|
|
747
|
+
context: ContextSpecs;
|
|
748
|
+
}) => Promise<GeneratorVerbsOptions>;
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Return the output type from an array
|
|
752
|
+
*
|
|
753
|
+
* @param item item with type === "array"
|
|
754
|
+
*/
|
|
755
|
+
declare const getArray: ({ schema, name, context, }: {
|
|
756
|
+
schema: SchemaObject;
|
|
757
|
+
name?: string | undefined;
|
|
758
|
+
context: ContextSpecs;
|
|
759
|
+
}) => ResolverValue;
|
|
760
|
+
|
|
761
|
+
declare const getBody: ({ requestBody, operationName, context, contentType, }: {
|
|
762
|
+
requestBody: ReferenceObject | RequestBodyObject;
|
|
763
|
+
operationName: string;
|
|
764
|
+
context: ContextSpecs;
|
|
765
|
+
contentType?: OverrideOutputContentType | undefined;
|
|
766
|
+
}) => GetterBody;
|
|
767
|
+
|
|
768
|
+
declare type Separator = 'allOf' | 'anyOf' | 'oneOf';
|
|
769
|
+
declare const combineSchemas: ({ name, schema, separator, context, nullable, }: {
|
|
770
|
+
name?: string | undefined;
|
|
771
|
+
schema: SchemaObject;
|
|
772
|
+
separator: Separator;
|
|
773
|
+
context: ContextSpecs;
|
|
774
|
+
nullable: string;
|
|
775
|
+
}) => {
|
|
776
|
+
value: string;
|
|
777
|
+
imports: GeneratorImport[];
|
|
778
|
+
schemas: GeneratorSchema[];
|
|
779
|
+
isEnum: boolean;
|
|
780
|
+
type: SchemaType;
|
|
781
|
+
isRef: boolean;
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
declare const resolveDiscriminators: (schemas: SchemasObject, context: ContextSpecs) => SchemasObject;
|
|
785
|
+
|
|
786
|
+
declare const getEnum: (value: string, enumName: string) => string;
|
|
787
|
+
declare const getEnumImplementation: (value: string) => string;
|
|
788
|
+
|
|
789
|
+
declare const getKey: (key: string) => string;
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Return the output type from an object
|
|
793
|
+
*
|
|
794
|
+
* @param item item with type === "object"
|
|
795
|
+
*/
|
|
796
|
+
declare const getObject: ({ item, name, context, nullable, }: {
|
|
797
|
+
item: SchemaObject;
|
|
798
|
+
name?: string | undefined;
|
|
799
|
+
context: ContextSpecs;
|
|
800
|
+
nullable: string;
|
|
801
|
+
}) => ResolverValue;
|
|
802
|
+
|
|
803
|
+
declare const getOperationId: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
804
|
+
|
|
805
|
+
declare const getParameters: ({ parameters, context, }: {
|
|
806
|
+
parameters: (ReferenceObject | ParameterObject)[];
|
|
807
|
+
context: ContextSpecs;
|
|
808
|
+
}) => GetterParameters;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Return every params in a path
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* ```
|
|
815
|
+
* getParamsInPath("/pet/{category}/{name}/");
|
|
816
|
+
* // => ["category", "name"]
|
|
817
|
+
* ```
|
|
818
|
+
* @param path
|
|
819
|
+
*/
|
|
820
|
+
declare const getParamsInPath: (path: string) => string[];
|
|
821
|
+
declare const getParams: ({ route, pathParams, operationId, context, }: {
|
|
822
|
+
route: string;
|
|
823
|
+
pathParams?: {
|
|
824
|
+
parameter: openapi3_ts.ParameterObject;
|
|
825
|
+
imports: GeneratorImport[];
|
|
826
|
+
}[] | undefined;
|
|
827
|
+
operationId: string;
|
|
828
|
+
context: ContextSpecs;
|
|
829
|
+
}) => GetterParams;
|
|
830
|
+
|
|
831
|
+
declare const getProps: ({ body, queryParams, params, headers, }: {
|
|
832
|
+
body: GetterBody;
|
|
833
|
+
queryParams?: GetterQueryParam | undefined;
|
|
834
|
+
params: GetterParams;
|
|
835
|
+
headers?: GetterQueryParam | undefined;
|
|
836
|
+
}) => GetterProps;
|
|
837
|
+
|
|
838
|
+
declare const getQueryParams: ({ queryParams, operationName, context, suffix, }: {
|
|
839
|
+
queryParams: GetterParameters['query'];
|
|
840
|
+
operationName: string;
|
|
841
|
+
context: ContextSpecs;
|
|
842
|
+
suffix?: string | undefined;
|
|
843
|
+
}) => GetterQueryParam | undefined;
|
|
844
|
+
|
|
845
|
+
declare type RefComponent = 'schemas' | 'responses' | 'parameters' | 'requestBodies';
|
|
846
|
+
declare const RefComponent: {
|
|
847
|
+
schemas: RefComponent;
|
|
848
|
+
responses: RefComponent;
|
|
849
|
+
parameters: RefComponent;
|
|
850
|
+
requestBodies: RefComponent;
|
|
851
|
+
};
|
|
852
|
+
declare const RefComponentSuffix: Record<RefComponent, string>;
|
|
853
|
+
/**
|
|
854
|
+
* Return the output type from the $ref
|
|
855
|
+
*
|
|
856
|
+
* @param $ref
|
|
857
|
+
*/
|
|
858
|
+
declare const getRefInfo: ($ref: ReferenceObject['$ref'], context: ContextSpecs) => {
|
|
859
|
+
name: string;
|
|
860
|
+
originalName: string;
|
|
861
|
+
refPaths?: string[] | undefined;
|
|
862
|
+
specKey?: string | undefined;
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
declare const getResReqTypes: (responsesOrRequests: Array<[
|
|
866
|
+
string,
|
|
867
|
+
ResponseObject | ReferenceObject | RequestBodyObject
|
|
868
|
+
]>, name: string, context: ContextSpecs, defaultType?: string) => ResReqTypesValue[];
|
|
869
|
+
|
|
870
|
+
declare const getResponse: ({ responses, operationName, context, contentType, }: {
|
|
871
|
+
responses: ResponsesObject;
|
|
872
|
+
operationName: string;
|
|
873
|
+
context: ContextSpecs;
|
|
874
|
+
contentType?: OverrideOutputContentType | undefined;
|
|
875
|
+
}) => GetterResponse;
|
|
876
|
+
|
|
877
|
+
declare const getRoute: (route: string) => string;
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Return the typescript equivalent of open-api data type
|
|
881
|
+
*
|
|
882
|
+
* @param item
|
|
883
|
+
* @ref https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#data-types
|
|
884
|
+
*/
|
|
885
|
+
declare const getScalar: ({ item, name, context, }: {
|
|
886
|
+
item: SchemaObject;
|
|
887
|
+
name?: string | undefined;
|
|
888
|
+
context: ContextSpecs;
|
|
889
|
+
}) => ResolverValue;
|
|
890
|
+
|
|
891
|
+
declare const resolveObject: ({ schema, propName, combined, context, }: {
|
|
892
|
+
schema: SchemaObject | ReferenceObject;
|
|
893
|
+
propName?: string | undefined;
|
|
894
|
+
combined?: boolean | undefined;
|
|
895
|
+
context: ContextSpecs;
|
|
896
|
+
}) => ResolverValue;
|
|
897
|
+
|
|
898
|
+
declare type ComponentObject = SchemaObject | ResponseObject | ParameterObject | RequestBodyObject | ReferenceObject;
|
|
899
|
+
declare const resolveRef: <Schema extends ComponentObject = ComponentObject>(schema: ComponentObject, context: ContextSpecs, imports?: GeneratorImport[]) => {
|
|
900
|
+
schema: Schema;
|
|
901
|
+
imports: GeneratorImport[];
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
declare const resolveValue: ({ schema, name, context, }: {
|
|
905
|
+
schema: SchemaObject | ReferenceObject;
|
|
906
|
+
name?: string | undefined;
|
|
907
|
+
context: ContextSpecs;
|
|
908
|
+
}) => ResolverValue;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Discriminator helper for `ReferenceObject`
|
|
912
|
+
*
|
|
913
|
+
* @param property
|
|
914
|
+
*/
|
|
915
|
+
declare const isReference: (property: any) => property is ReferenceObject;
|
|
916
|
+
declare const isDirectory: (path: string) => boolean;
|
|
917
|
+
declare function isObject(x: any): x is Record<string, unknown>;
|
|
918
|
+
declare function isString(x: any): x is string;
|
|
919
|
+
declare function isNumber(x: any): x is number;
|
|
920
|
+
declare function isBoolean(x: any): x is boolean;
|
|
921
|
+
declare function isFunction(x: any): x is Function;
|
|
922
|
+
declare function isUndefined(x: any): x is undefined;
|
|
923
|
+
declare function isNull(x: any): x is null;
|
|
924
|
+
declare const isVerb: (verb: string) => verb is Verbs;
|
|
925
|
+
declare const isRootKey: (specKey: string, target: string) => boolean;
|
|
926
|
+
declare const isUrl: (str: string) => boolean;
|
|
927
|
+
|
|
928
|
+
declare function asyncReduce<IterationItem, AccValue>(array: IterationItem[], reducer: (accumulate: AccValue, current: IterationItem) => AccValue | Promise<AccValue>, initValue: AccValue): Promise<AccValue>;
|
|
929
|
+
|
|
930
|
+
declare const pascal: (s: string) => string;
|
|
931
|
+
declare const camel: (s: string) => string;
|
|
932
|
+
declare const snake: (s: string) => string;
|
|
933
|
+
declare const kebab: (s: string) => string;
|
|
934
|
+
declare const upper: (s: string, fillWith?: string, isDeapostrophe?: boolean) => string;
|
|
935
|
+
|
|
936
|
+
declare const compareVersions: (firstVersion: string, secondVersions: string, operator?: CompareOperator) => boolean;
|
|
937
|
+
|
|
938
|
+
interface DebuggerOptions {
|
|
939
|
+
onlyWhenFocused?: boolean | string;
|
|
940
|
+
}
|
|
941
|
+
declare function createDebugger(ns: string, options?: DebuggerOptions): debug.Debugger['log'];
|
|
942
|
+
|
|
943
|
+
declare function jsDoc({ description, deprecated, summary, }: {
|
|
944
|
+
description?: string[] | string;
|
|
945
|
+
deprecated?: boolean;
|
|
946
|
+
summary?: string;
|
|
947
|
+
}, tryOneLine?: boolean): string;
|
|
948
|
+
|
|
949
|
+
declare const dynamicImport: <T>(toImport: string | T, from?: string, takeDefault?: boolean) => Promise<T>;
|
|
950
|
+
|
|
951
|
+
declare const getExtension: (path: string) => "yaml" | "json";
|
|
952
|
+
|
|
953
|
+
declare const log: {
|
|
954
|
+
(...data: any[]): void;
|
|
955
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
956
|
+
};
|
|
957
|
+
declare const startMessage: ({ name, version, description, }: {
|
|
958
|
+
name: string;
|
|
959
|
+
version: string;
|
|
960
|
+
description: string;
|
|
961
|
+
}) => void;
|
|
962
|
+
declare const errorMessage: (err: string) => void;
|
|
963
|
+
declare const mismatchArgsMessage: (mismatchArgs: string[]) => void;
|
|
964
|
+
declare const createSuccessMessage: (backend?: string) => void;
|
|
965
|
+
declare const ibmOpenapiValidatorWarnings: (warnings: {
|
|
966
|
+
path: string;
|
|
967
|
+
message: string;
|
|
968
|
+
}[]) => void;
|
|
969
|
+
declare const ibmOpenapiValidatorErrors: (errors: {
|
|
970
|
+
path: string;
|
|
971
|
+
message: string;
|
|
972
|
+
}[]) => void;
|
|
973
|
+
declare type LogType = 'error' | 'warn' | 'info';
|
|
974
|
+
declare type LogLevel = LogType | 'silent';
|
|
975
|
+
interface Logger {
|
|
976
|
+
info(msg: string, options?: LogOptions): void;
|
|
977
|
+
warn(msg: string, options?: LogOptions): void;
|
|
978
|
+
warnOnce(msg: string, options?: LogOptions): void;
|
|
979
|
+
error(msg: string, options?: LogOptions): void;
|
|
980
|
+
clearScreen(type: LogType): void;
|
|
981
|
+
hasWarned: boolean;
|
|
982
|
+
}
|
|
983
|
+
interface LogOptions {
|
|
984
|
+
clear?: boolean;
|
|
985
|
+
timestamp?: boolean;
|
|
986
|
+
}
|
|
987
|
+
declare const LogLevels: Record<LogLevel, number>;
|
|
988
|
+
interface LoggerOptions {
|
|
989
|
+
prefix?: string;
|
|
990
|
+
allowClearScreen?: boolean;
|
|
991
|
+
}
|
|
992
|
+
declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
|
|
993
|
+
|
|
994
|
+
declare const getFileInfo: (target?: string, { backupFilename, extension, }?: {
|
|
995
|
+
backupFilename?: string | undefined;
|
|
996
|
+
extension?: string | undefined;
|
|
997
|
+
}) => {
|
|
998
|
+
path: string;
|
|
999
|
+
pathWithoutExtension: string;
|
|
1000
|
+
extension: string;
|
|
1001
|
+
isDirectory: boolean;
|
|
1002
|
+
dirname: string;
|
|
1003
|
+
filename: string;
|
|
1004
|
+
};
|
|
1005
|
+
declare function loadFile<File = any>(filePath?: string, options?: {
|
|
1006
|
+
root?: string;
|
|
1007
|
+
defaultFileName?: string;
|
|
1008
|
+
logLevel?: LogLevel;
|
|
1009
|
+
isDefault?: boolean;
|
|
1010
|
+
alias?: Record<string, string>;
|
|
1011
|
+
tsconfig?: Tsconfig;
|
|
1012
|
+
load?: boolean;
|
|
1013
|
+
}): Promise<{
|
|
1014
|
+
path: string;
|
|
1015
|
+
file?: File;
|
|
1016
|
+
error?: any;
|
|
1017
|
+
cached?: boolean;
|
|
1018
|
+
}>;
|
|
1019
|
+
declare function removeFiles(patterns: string[], dir: string): Promise<void>;
|
|
1020
|
+
|
|
1021
|
+
declare function mergeDeep<T extends Record<string, any>>(source: T, target: T): T;
|
|
1022
|
+
|
|
1023
|
+
declare const count: (str: string | undefined, key: string) => number;
|
|
1024
|
+
|
|
1025
|
+
declare const openApiConverter: (schema: any, options: swagger2openapi.Options | undefined, specKey: string) => Promise<OpenAPIObject>;
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Behaves exactly like `path.relative(from, to)`, but keeps the first meaningful "./"
|
|
1029
|
+
*/
|
|
1030
|
+
declare const relativeSafe: (from: string, to: string) => string;
|
|
1031
|
+
declare const getSpecName: (specKey: string, target: string) => string;
|
|
1032
|
+
|
|
1033
|
+
declare const sortByPriority: <T>(arr: (T & {
|
|
1034
|
+
default?: boolean | undefined;
|
|
1035
|
+
required?: boolean | undefined;
|
|
1036
|
+
})[]) => (T & {
|
|
1037
|
+
default?: boolean | undefined;
|
|
1038
|
+
required?: boolean | undefined;
|
|
1039
|
+
})[];
|
|
1040
|
+
|
|
1041
|
+
declare const stringify: (data?: string | any[] | {
|
|
1042
|
+
[key: string]: any;
|
|
1043
|
+
} | undefined) => string | undefined;
|
|
1044
|
+
declare const sanitize: (value: string, options?: {
|
|
1045
|
+
whitespace?: string | true;
|
|
1046
|
+
underscore?: string | true;
|
|
1047
|
+
dot?: string | true;
|
|
1048
|
+
dash?: string | true;
|
|
1049
|
+
es5keyword?: boolean;
|
|
1050
|
+
es5IdentifierName?: boolean;
|
|
1051
|
+
special?: boolean;
|
|
1052
|
+
}) => string;
|
|
1053
|
+
declare const toObjectString: <T>(props: T[], path?: keyof T | undefined) => string;
|
|
1054
|
+
declare const getNumberWord: (num: number) => string;
|
|
1055
|
+
declare const escape: (str: string, char?: string) => string;
|
|
1056
|
+
|
|
1057
|
+
declare const isSyntheticDefaultImportsAllow: (config?: Tsconfig) => boolean;
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* Validate the spec with ibm-openapi-validator (with a custom pretty logger).
|
|
1061
|
+
* More information: https://github.com/IBM/openapi-validator/#configuration
|
|
1062
|
+
* @param specs openAPI spec
|
|
1063
|
+
*/
|
|
1064
|
+
declare const ibmOpenapiValidator: (specs: OpenAPIObject) => Promise<void>;
|
|
1065
|
+
|
|
1066
|
+
declare const writeModelInline: (acc: string, model: string) => string;
|
|
1067
|
+
declare const writeModelsInline: (array: GeneratorSchema[]) => string;
|
|
1068
|
+
declare const writeSchema: ({ path, schema, target, isRootKey, specsName, header, }: {
|
|
1069
|
+
path: string;
|
|
1070
|
+
schema: GeneratorSchema;
|
|
1071
|
+
target: string;
|
|
1072
|
+
isRootKey: boolean;
|
|
1073
|
+
specsName: Record<string, string>;
|
|
1074
|
+
header: string;
|
|
1075
|
+
}) => Promise<void>;
|
|
1076
|
+
declare const writeSchemas: ({ schemaPath, schemas, target, isRootKey, specsName, header, }: {
|
|
1077
|
+
schemaPath: string;
|
|
1078
|
+
schemas: GeneratorSchema[];
|
|
1079
|
+
target: string;
|
|
1080
|
+
isRootKey: boolean;
|
|
1081
|
+
specsName: Record<string, string>;
|
|
1082
|
+
header: string;
|
|
1083
|
+
}) => Promise<void>;
|
|
1084
|
+
|
|
1085
|
+
declare const writeSingleMode: ({ builder, output, specsName, header, }: WriteModeProps) => Promise<string[]>;
|
|
1086
|
+
|
|
1087
|
+
declare const writeSplitMode: ({ builder, output, specsName, header, }: WriteModeProps) => Promise<string[]>;
|
|
1088
|
+
|
|
1089
|
+
declare const writeSplitTagsMode: ({ builder, output, specsName, header, }: WriteModeProps) => Promise<string[]>;
|
|
1090
|
+
|
|
1091
|
+
declare const writeTagsMode: ({ builder, output, specsName, header, }: WriteModeProps) => Promise<string[]>;
|
|
1092
|
+
|
|
1093
|
+
declare const generateTarget: (builder: WriteSpecsBuilder, options: NormalizedOutputOptions) => GeneratorTarget;
|
|
1094
|
+
|
|
1095
|
+
declare const generateTargetForTags: (builder: WriteSpecsBuilder, options: NormalizedOutputOptions) => Record<string, GeneratorTarget>;
|
|
1096
|
+
|
|
1097
|
+
export { AngularOptions, BODY_TYPE_NAME, ClientBuilder, ClientDependenciesBuilder, ClientFooterBuilder, ClientGeneratorsBuilder, ClientHeaderBuilder, ClientMSWBuilder, ClientTitleBuilder, Config, ConfigExternal, ConfigFn, ContextSpecs, GenerateMockImports, GeneratorApiBuilder, GeneratorApiOperations, GeneratorApiResponse, GeneratorClient, GeneratorClientExtra, GeneratorClientFooter, GeneratorClientHeader, GeneratorClientImports, GeneratorClientTitle, GeneratorClients, GeneratorDependency, GeneratorImport, GeneratorMutator, GeneratorMutatorParsingInfo, GeneratorOperation, GeneratorOperations, GeneratorOptions, GeneratorSchema, GeneratorTarget, GeneratorTargetFull, GeneratorVerbOptions, GeneratorVerbsOptions, GetterBody, GetterParam, GetterParameters, GetterParams, GetterProp, GetterPropType, GetterProps, GetterQueryParam, GetterResponse, GlobalOptions, Hook, HookCommand, HookFunction, HooksOptions, ImportOpenApi, InputOptions, InputTransformerFn, LogLevel, LogLevels, LogOptions, LogType, Logger, LoggerOptions, MockOptions, MockProperties, Mutator, MutatorObject, NormalizedHookCommand, NormalizedHookOptions, NormalizedInputOptions, NormalizedMutator, NormalizedOperationOptions, NormalizedOptions, NormalizedOutputOptions, NormalizedOverrideOutput, NormizaledConfig, OperationOptions, Options, OptionsExport, OptionsFn, OutputClient, OutputClientFunc, OutputMode, OutputOptions, OverrideInput, OverrideOutput, OverrideOutputContentType, PackageJson, RefComponentSuffix, ResReqTypesValue, ResolverValue, SchemaType, SwaggerParserOptions, Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, WriteModeProps, WriteSpecsBuilder, addDependency, asyncReduce, camel, combineSchemas, compareVersions, count, createDebugger, createLogger, createSuccessMessage, dynamicImport, errorMessage, escape, generalJSTypes, generalJSTypesWithArray, generateAxiosOptions, generateBodyMutatorConfig, generateBodyOptions, generateComponentDefinition, generateDependencyImports, generateFormDataAndUrlEncodedFunction, generateImports, generateModelInline, generateModelsInline, generateMutator, generateMutatorConfig, generateMutatorImports, generateMutatorRequestOptions, generateOptions, generateParameterDefinition, generateQueryParamsAxiosConfig, generateSchemasDefinition, generateTarget, generateTargetForTags, generateVerbImports, generateVerbsOptions, getArray, getBody, getEnum, getEnumImplementation, getExtension, getFileInfo, getKey, getNumberWord, getObject, getOperationId, getParameters, getParams, getParamsInPath, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getRoute, getScalar, getSpecName, ibmOpenapiValidator, ibmOpenapiValidatorErrors, ibmOpenapiValidatorWarnings, isBoolean, isDirectory, isFunction, isNull, isNumber, isObject, isReference, isRootKey, isString, isSyntheticDefaultImportsAllow, isUndefined, isUrl, isVerb, jsDoc, kebab, loadFile, log, mergeDeep, mismatchArgsMessage, openApiConverter, pascal, relativeSafe, removeFiles, resolveDiscriminators, resolveObject, resolveRef, resolveValue, sanitize, snake, sortByPriority, startMessage, stringify, toObjectString, upper, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
|