@orval/core 6.20.0 → 6.21.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.
- package/dist/index.d.ts +55 -69
- package/dist/index.js +4163 -4516
- package/dist/index.js.map +1 -0
- package/package.json +14 -15
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import SwaggerParser from '@apidevtools/swagger-parser';
|
|
|
2
2
|
import * as openapi3_ts from 'openapi3-ts';
|
|
3
3
|
import { InfoObject, OperationObject, OpenAPIObject, ResponsesObject, ReferenceObject, RequestBodyObject, ParameterObject, SchemaObject, ComponentsObject, SchemasObject, PathItemObject, ResponseObject, ExampleObject } from 'openapi3-ts';
|
|
4
4
|
import swagger2openapi from 'swagger2openapi';
|
|
5
|
+
import { allLocales } from '@faker-js/faker';
|
|
5
6
|
import { CompareOperator } from 'compare-versions';
|
|
6
7
|
import debug from 'debug';
|
|
7
8
|
|
|
@@ -30,7 +31,7 @@ type NormalizedOutputOptions = {
|
|
|
30
31
|
target?: string;
|
|
31
32
|
schemas?: string;
|
|
32
33
|
mode: OutputMode;
|
|
33
|
-
mock
|
|
34
|
+
mock?: GlobalMockOptions | ClientMockBuilder;
|
|
34
35
|
override: NormalizedOverrideOutput;
|
|
35
36
|
client: OutputClient | OutputClientFunc;
|
|
36
37
|
clean: boolean | string[];
|
|
@@ -55,18 +56,7 @@ type NormalizedOverrideOutput = {
|
|
|
55
56
|
tags: {
|
|
56
57
|
[key: string]: NormalizedOperationOptions;
|
|
57
58
|
};
|
|
58
|
-
mock?:
|
|
59
|
-
arrayMin?: number;
|
|
60
|
-
arrayMax?: number;
|
|
61
|
-
properties?: MockProperties;
|
|
62
|
-
format?: {
|
|
63
|
-
[key: string]: unknown;
|
|
64
|
-
};
|
|
65
|
-
required?: boolean;
|
|
66
|
-
baseUrl?: string;
|
|
67
|
-
delay?: number | (() => number);
|
|
68
|
-
useExamples?: boolean;
|
|
69
|
-
};
|
|
59
|
+
mock?: OverrideMockOptions;
|
|
70
60
|
contentType?: OverrideOutputContentType;
|
|
71
61
|
header: false | ((info: InfoObject) => string[] | string);
|
|
72
62
|
formData: boolean | NormalizedMutator;
|
|
@@ -95,10 +85,12 @@ type NormalizedOverrideOutput = {
|
|
|
95
85
|
operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
96
86
|
requestOptions: Record<string, any> | boolean;
|
|
97
87
|
useDates?: boolean;
|
|
88
|
+
coerceTypes?: boolean;
|
|
98
89
|
useTypeOverInterfaces?: boolean;
|
|
99
90
|
useDeprecatedOperations?: boolean;
|
|
100
91
|
useBigInt?: boolean;
|
|
101
92
|
useNamedParameters?: boolean;
|
|
93
|
+
useNativeEnums?: boolean;
|
|
102
94
|
};
|
|
103
95
|
type NormalizedMutator = {
|
|
104
96
|
path: string;
|
|
@@ -141,7 +133,7 @@ type OutputOptions = {
|
|
|
141
133
|
target?: string;
|
|
142
134
|
schemas?: string;
|
|
143
135
|
mode?: OutputMode;
|
|
144
|
-
mock?: boolean |
|
|
136
|
+
mock?: boolean | GlobalMockOptions | ClientMockBuilder;
|
|
145
137
|
override?: OverrideOutput;
|
|
146
138
|
client?: OutputClient | OutputClientFunc;
|
|
147
139
|
clean?: boolean | string[];
|
|
@@ -166,33 +158,47 @@ type InputOptions = {
|
|
|
166
158
|
tags?: string[];
|
|
167
159
|
};
|
|
168
160
|
};
|
|
169
|
-
type OutputClient = 'axios' | 'axios-functions' | 'angular' | 'react-query' | 'svelte-query' | 'vue-query' | 'swr' | 'zod';
|
|
170
161
|
declare const OutputClient: {
|
|
171
|
-
ANGULAR:
|
|
172
|
-
AXIOS:
|
|
173
|
-
AXIOS_FUNCTIONS:
|
|
174
|
-
REACT_QUERY:
|
|
175
|
-
SVELTE_QUERY:
|
|
176
|
-
VUE_QUERY:
|
|
162
|
+
readonly ANGULAR: "angular";
|
|
163
|
+
readonly AXIOS: "axios";
|
|
164
|
+
readonly AXIOS_FUNCTIONS: "axios-functions";
|
|
165
|
+
readonly REACT_QUERY: "react-query";
|
|
166
|
+
readonly SVELTE_QUERY: "svelte-query";
|
|
167
|
+
readonly VUE_QUERY: "vue-query";
|
|
177
168
|
};
|
|
178
|
-
type
|
|
169
|
+
type OutputClient = typeof OutputClient[keyof typeof OutputClient];
|
|
179
170
|
declare const OutputMode: {
|
|
180
|
-
SINGLE:
|
|
181
|
-
SPLIT:
|
|
182
|
-
TAGS:
|
|
183
|
-
TAGS_SPLIT:
|
|
171
|
+
readonly SINGLE: "single";
|
|
172
|
+
readonly SPLIT: "split";
|
|
173
|
+
readonly TAGS: "tags";
|
|
174
|
+
readonly TAGS_SPLIT: "tags-split";
|
|
175
|
+
};
|
|
176
|
+
type OutputMode = typeof OutputMode[keyof typeof OutputMode];
|
|
177
|
+
declare const OutputMockType: {
|
|
178
|
+
readonly MSW: "msw";
|
|
179
|
+
};
|
|
180
|
+
type OutputMockType = typeof OutputMockType[keyof typeof OutputMockType];
|
|
181
|
+
type GlobalMockOptions = {
|
|
182
|
+
type: OutputMockType;
|
|
183
|
+
useExamples?: boolean;
|
|
184
|
+
delay?: number | (() => number);
|
|
185
|
+
baseUrl?: string;
|
|
186
|
+
locale?: keyof typeof allLocales;
|
|
184
187
|
};
|
|
185
|
-
type
|
|
188
|
+
type OverrideMockOptions = Partial<GlobalMockOptions> & {
|
|
186
189
|
arrayMin?: number;
|
|
187
190
|
arrayMax?: number;
|
|
188
191
|
required?: boolean;
|
|
189
|
-
properties?:
|
|
192
|
+
properties?: MockProperties;
|
|
193
|
+
format?: Record<string, unknown>;
|
|
194
|
+
};
|
|
195
|
+
type MockOptions = Omit<OverrideMockOptions, 'properties'> & {
|
|
196
|
+
properties?: Record<string, unknown>;
|
|
190
197
|
operations?: Record<string, {
|
|
191
|
-
properties: Record<string,
|
|
198
|
+
properties: Record<string, unknown>;
|
|
192
199
|
}>;
|
|
193
|
-
format?: Record<string, string>;
|
|
194
200
|
tags?: Record<string, {
|
|
195
|
-
properties: Record<string,
|
|
201
|
+
properties: Record<string, unknown>;
|
|
196
202
|
}>;
|
|
197
203
|
};
|
|
198
204
|
type MockProperties = {
|
|
@@ -222,18 +228,7 @@ type OverrideOutput = {
|
|
|
222
228
|
tags?: {
|
|
223
229
|
[key: string]: OperationOptions;
|
|
224
230
|
};
|
|
225
|
-
mock?:
|
|
226
|
-
arrayMin?: number;
|
|
227
|
-
arrayMax?: number;
|
|
228
|
-
properties?: MockProperties;
|
|
229
|
-
format?: {
|
|
230
|
-
[key: string]: unknown;
|
|
231
|
-
};
|
|
232
|
-
required?: boolean;
|
|
233
|
-
baseUrl?: string;
|
|
234
|
-
delay?: number;
|
|
235
|
-
useExamples?: boolean;
|
|
236
|
-
};
|
|
231
|
+
mock?: OverrideMockOptions;
|
|
237
232
|
contentType?: OverrideOutputContentType;
|
|
238
233
|
header?: boolean | ((info: InfoObject) => string[] | string);
|
|
239
234
|
formData?: boolean | Mutator;
|
|
@@ -266,6 +261,7 @@ type OverrideOutput = {
|
|
|
266
261
|
useDeprecatedOperations?: boolean;
|
|
267
262
|
useBigInt?: boolean;
|
|
268
263
|
useNamedParameters?: boolean;
|
|
264
|
+
useNativeEnums?: boolean;
|
|
269
265
|
};
|
|
270
266
|
type OverrideOutputContentType = {
|
|
271
267
|
include?: string[];
|
|
@@ -366,7 +362,7 @@ interface GlobalOptions {
|
|
|
366
362
|
clean?: boolean | string[];
|
|
367
363
|
prettier?: boolean;
|
|
368
364
|
tslint?: boolean;
|
|
369
|
-
mock?: boolean;
|
|
365
|
+
mock?: boolean | GlobalMockOptions;
|
|
370
366
|
client?: OutputClient;
|
|
371
367
|
mode?: OutputMode;
|
|
372
368
|
tsconfig?: string | Tsconfig;
|
|
@@ -417,8 +413,8 @@ type GeneratorOperations = {
|
|
|
417
413
|
type GeneratorTarget = {
|
|
418
414
|
imports: GeneratorImport[];
|
|
419
415
|
implementation: string;
|
|
420
|
-
|
|
421
|
-
|
|
416
|
+
implementationMock: string;
|
|
417
|
+
importsMock: GeneratorImport[];
|
|
422
418
|
mutators?: GeneratorMutator[];
|
|
423
419
|
clientMutators?: GeneratorMutator[];
|
|
424
420
|
formData?: GeneratorMutator[];
|
|
@@ -428,11 +424,11 @@ type GeneratorTarget = {
|
|
|
428
424
|
type GeneratorTargetFull = {
|
|
429
425
|
imports: GeneratorImport[];
|
|
430
426
|
implementation: string;
|
|
431
|
-
|
|
427
|
+
implementationMock: {
|
|
432
428
|
function: string;
|
|
433
429
|
handler: string;
|
|
434
430
|
};
|
|
435
|
-
|
|
431
|
+
importsMock: GeneratorImport[];
|
|
436
432
|
mutators?: GeneratorMutator[];
|
|
437
433
|
clientMutators?: GeneratorMutator[];
|
|
438
434
|
formData?: GeneratorMutator[];
|
|
@@ -442,11 +438,11 @@ type GeneratorTargetFull = {
|
|
|
442
438
|
type GeneratorOperation = {
|
|
443
439
|
imports: GeneratorImport[];
|
|
444
440
|
implementation: string;
|
|
445
|
-
|
|
441
|
+
implementationMock: {
|
|
446
442
|
function: string;
|
|
447
443
|
handler: string;
|
|
448
444
|
};
|
|
449
|
-
|
|
445
|
+
importsMock: GeneratorImport[];
|
|
450
446
|
tags: string[];
|
|
451
447
|
mutator?: GeneratorMutator;
|
|
452
448
|
clientMutators?: GeneratorMutator[];
|
|
@@ -485,7 +481,7 @@ type GeneratorOptions = {
|
|
|
485
481
|
pathRoute: string;
|
|
486
482
|
override: NormalizedOverrideOutput;
|
|
487
483
|
context: ContextSpecs;
|
|
488
|
-
mock
|
|
484
|
+
mock?: GlobalMockOptions | ClientMockBuilder;
|
|
489
485
|
output: string;
|
|
490
486
|
};
|
|
491
487
|
type GeneratorClient = {
|
|
@@ -527,7 +523,7 @@ type ClientFooterBuilder = (params: {
|
|
|
527
523
|
}) => string;
|
|
528
524
|
type ClientTitleBuilder = (title: string) => string;
|
|
529
525
|
type ClientDependenciesBuilder = (hasGlobalMutator: boolean, hasParamsSerializerOptions: boolean, packageJson?: PackageJson) => GeneratorDependency[];
|
|
530
|
-
type
|
|
526
|
+
type ClientMockBuilder = (verbOptions: GeneratorVerbOptions, generatorOptions: GeneratorOptions) => {
|
|
531
527
|
imports: string[];
|
|
532
528
|
implementation: string;
|
|
533
529
|
};
|
|
@@ -676,7 +672,7 @@ type GeneratorApiOperations = {
|
|
|
676
672
|
};
|
|
677
673
|
type GeneratorClientExtra = {
|
|
678
674
|
implementation: string;
|
|
679
|
-
|
|
675
|
+
implementationMock: string;
|
|
680
676
|
};
|
|
681
677
|
type GeneratorClientTitle = (data: {
|
|
682
678
|
outputClient?: OutputClient | OutputClientFunc;
|
|
@@ -722,6 +718,7 @@ type GenerateMockImports = (data: {
|
|
|
722
718
|
specsName: Record<string, string>;
|
|
723
719
|
hasSchemaDir: boolean;
|
|
724
720
|
isAllowSyntheticDefaultImports: boolean;
|
|
721
|
+
options?: GlobalMockOptions;
|
|
725
722
|
}) => string;
|
|
726
723
|
type GeneratorApiBuilder = GeneratorApiOperations & {
|
|
727
724
|
title: GeneratorClientTitle;
|
|
@@ -874,7 +871,7 @@ declare const combineSchemas: ({ name, schema, separator, context, nullable, }:
|
|
|
874
871
|
|
|
875
872
|
declare const resolveDiscriminators: (schemas: SchemasObject, context: ContextSpecs) => SchemasObject;
|
|
876
873
|
|
|
877
|
-
declare const getEnum: (value: string, enumName: string, names?: string[]) => string;
|
|
874
|
+
declare const getEnum: (value: string, enumName: string, names?: string[], useNativeEnums?: boolean) => string;
|
|
878
875
|
declare const getEnumImplementation: (value: string, names?: string[]) => string;
|
|
879
876
|
|
|
880
877
|
declare const getKey: (key: string) => string;
|
|
@@ -1119,6 +1116,8 @@ declare function loadFile<File = any>(filePath?: string, options?: {
|
|
|
1119
1116
|
}>;
|
|
1120
1117
|
declare function removeFiles(patterns: string[], dir: string): Promise<void>;
|
|
1121
1118
|
|
|
1119
|
+
declare const getMockFileExtensionByTypeName: (mock: GlobalMockOptions | ClientMockBuilder) => string;
|
|
1120
|
+
|
|
1122
1121
|
declare function mergeDeep<T extends Record<string, any>>(source: T, target: T): T;
|
|
1123
1122
|
|
|
1124
1123
|
declare const count: (str: string | undefined, key: string) => number;
|
|
@@ -1155,20 +1154,7 @@ declare const path_relativeSafe: typeof relativeSafe;
|
|
|
1155
1154
|
declare const path_resolve: typeof resolve;
|
|
1156
1155
|
declare const path_separator: typeof separator;
|
|
1157
1156
|
declare namespace path {
|
|
1158
|
-
export {
|
|
1159
|
-
path_basename as basename,
|
|
1160
|
-
path_dirname as dirname,
|
|
1161
|
-
path_extname as extname,
|
|
1162
|
-
path_getSchemaFileName as getSchemaFileName,
|
|
1163
|
-
path_getSpecName as getSpecName,
|
|
1164
|
-
path_isAbsolute as isAbsolute,
|
|
1165
|
-
path_join as join,
|
|
1166
|
-
path_joinSafe as joinSafe,
|
|
1167
|
-
path_normalizeSafe as normalizeSafe,
|
|
1168
|
-
path_relativeSafe as relativeSafe,
|
|
1169
|
-
path_resolve as resolve,
|
|
1170
|
-
path_separator as separator,
|
|
1171
|
-
};
|
|
1157
|
+
export { path_basename as basename, path_dirname as dirname, path_extname as extname, path_getSchemaFileName as getSchemaFileName, path_getSpecName as getSpecName, path_isAbsolute as isAbsolute, path_join as join, path_joinSafe as joinSafe, path_normalizeSafe as normalizeSafe, path_relativeSafe as relativeSafe, path_resolve as resolve, path_separator as separator };
|
|
1172
1158
|
}
|
|
1173
1159
|
|
|
1174
1160
|
declare const sortByPriority: <T>(arr: (T & {
|
|
@@ -1250,4 +1236,4 @@ declare const generateTarget: (builder: WriteSpecsBuilder, options: NormalizedOu
|
|
|
1250
1236
|
|
|
1251
1237
|
declare const generateTargetForTags: (builder: WriteSpecsBuilder, options: NormalizedOutputOptions) => Record<string, GeneratorTarget>;
|
|
1252
1238
|
|
|
1253
|
-
export { AngularOptions, BODY_TYPE_NAME, ClientBuilder, ClientDependenciesBuilder, ClientFooterBuilder, ClientGeneratorsBuilder, ClientHeaderBuilder,
|
|
1239
|
+
export { type AngularOptions, BODY_TYPE_NAME, type ClientBuilder, type ClientDependenciesBuilder, type ClientFooterBuilder, type ClientGeneratorsBuilder, type ClientHeaderBuilder, type ClientMockBuilder, type ClientTitleBuilder, type Config, type ConfigExternal, type ConfigFn, type ContextSpecs, type GenerateMockImports, type GeneratorApiBuilder, type GeneratorApiOperations, type GeneratorApiResponse, type GeneratorClient, type GeneratorClientExtra, type GeneratorClientFooter, type GeneratorClientHeader, type GeneratorClientImports, type GeneratorClientTitle, type GeneratorClients, type GeneratorDependency, type GeneratorImport, type GeneratorMutator, type GeneratorMutatorParsingInfo, type GeneratorOperation, type GeneratorOperations, type GeneratorOptions, type GeneratorSchema, type GeneratorTarget, type GeneratorTargetFull, type GeneratorVerbOptions, type GeneratorVerbsOptions, type GetterBody, type GetterParam, type GetterParameters, type GetterParams, type GetterProp, GetterPropType, type GetterProps, type GetterQueryParam, type GetterResponse, type GlobalMockOptions, type GlobalOptions, type Hook, type HookCommand, type HookFunction, type HooksOptions, type ImportOpenApi, type InputOptions, type InputTransformerFn, type LogLevel, LogLevels, type LogOptions, type LogType, type Logger, type LoggerOptions, type MockOptions, type MockProperties, type Mutator, type MutatorObject, type NormalizedConfig, type NormalizedHookCommand, type NormalizedHookOptions, type NormalizedInputOptions, type NormalizedMutator, type NormalizedOperationOptions, type NormalizedOptions, type NormalizedOutputOptions, type NormalizedOverrideOutput, type NormalizedParamsSerializerOptions, type NormalizedQueryOptions, type OperationOptions, type Options, type OptionsExport, type OptionsFn, OutputClient, type OutputClientFunc, OutputMockType, OutputMode, type OutputOptions, type OverrideInput, type OverrideMockOptions, type OverrideOutput, type OverrideOutputContentType, type PackageJson, type ParamsSerializerOptions, type QueryOptions, RefComponentSuffix, type RefInfo, type ResReqTypesValue, type ResolverValue, type ScalarValue, SchemaType, type SwaggerParserOptions, type TsConfigTarget, type Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, type WriteModeProps, type WriteSpecsBuilder, _filteredVerbs, 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, getMockFileExtensionByTypeName, getNumberWord, getObject, getOperationId, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getRoute, getRouteAsArray, getScalar, ibmOpenapiValidator, ibmOpenapiValidatorErrors, ibmOpenapiValidatorWarnings, isBoolean, isDirectory, isFunction, isModule, isNull, isNumber, isNumeric, isObject, isReference, isRootKey, isSchema, isString, isSyntheticDefaultImportsAllow, isUndefined, isUrl, isVerb, jsDoc, jsStringEscape, kebab, loadFile, log, mergeDeep, mismatchArgsMessage, openApiConverter, pascal, removeFiles, resolveDiscriminators, resolveExampleRefs, resolveObject, resolveRef, resolveValue, sanitize, snake, sortByPriority, startMessage, stringify, toObjectString, path as upath, upper, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
|