@orval/core 6.25.0 → 6.27.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/README.md +1 -0
- package/dist/index.d.ts +84 -13
- package/dist/index.js +121 -53
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -26,3 +26,4 @@ You can find below some samples
|
|
|
26
26
|
- [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
|
|
27
27
|
- [nx fastify react](https://github.com/anymaniax/orval/tree/master/samples/nx-fastify-react)
|
|
28
28
|
- [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
|
|
29
|
+
- [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
|
3
3
|
import { InfoObject, OperationObject, OpenAPIObject, ResponsesObject, ReferenceObject, RequestBodyObject, ParameterObject, SchemaObject, ComponentsObject, SchemasObject, PathItemObject, ResponseObject, ExampleObject } from 'openapi3-ts/oas30';
|
|
4
4
|
import swagger2openapi from 'swagger2openapi';
|
|
5
5
|
import { allLocales } from '@faker-js/faker';
|
|
6
|
+
import { ValueIteratee } from 'lodash';
|
|
6
7
|
import { CompareOperator } from 'compare-versions';
|
|
7
8
|
import debug from 'debug';
|
|
8
9
|
|
|
@@ -81,9 +82,11 @@ type NormalizedOverrideOutput = {
|
|
|
81
82
|
suffix: string;
|
|
82
83
|
};
|
|
83
84
|
};
|
|
85
|
+
hono: NormalizedHonoOptions;
|
|
84
86
|
query: NormalizedQueryOptions;
|
|
85
87
|
angular: Required<AngularOptions>;
|
|
86
88
|
swr: SwrOptions;
|
|
89
|
+
zod: NormalizedZodOptions;
|
|
87
90
|
operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
88
91
|
requestOptions: Record<string, any> | boolean;
|
|
89
92
|
useDates?: boolean;
|
|
@@ -104,15 +107,14 @@ type NormalizedOperationOptions = {
|
|
|
104
107
|
transformer?: OutputTransformer;
|
|
105
108
|
mutator?: NormalizedMutator;
|
|
106
109
|
mock?: {
|
|
107
|
-
data?:
|
|
110
|
+
data?: MockData;
|
|
108
111
|
properties?: MockProperties;
|
|
109
112
|
};
|
|
110
113
|
contentType?: OverrideOutputContentType;
|
|
111
114
|
query?: NormalizedQueryOptions;
|
|
112
115
|
angular?: Required<AngularOptions>;
|
|
113
|
-
swr?:
|
|
114
|
-
|
|
115
|
-
};
|
|
116
|
+
swr?: SwrOptions;
|
|
117
|
+
zod?: NormalizedZodOptions;
|
|
116
118
|
operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
117
119
|
formData?: boolean | NormalizedMutator;
|
|
118
120
|
formUrlEncoded?: boolean | NormalizedMutator;
|
|
@@ -172,6 +174,7 @@ declare const OutputClient: {
|
|
|
172
174
|
readonly VUE_QUERY: "vue-query";
|
|
173
175
|
readonly SWR: "swr";
|
|
174
176
|
readonly ZOD: "zod";
|
|
177
|
+
readonly HONO: "hono";
|
|
175
178
|
};
|
|
176
179
|
type OutputClient = (typeof OutputClient)[keyof typeof OutputClient];
|
|
177
180
|
declare const OutputMode: {
|
|
@@ -188,7 +191,9 @@ type OutputMockType = (typeof OutputMockType)[keyof typeof OutputMockType];
|
|
|
188
191
|
type GlobalMockOptions = {
|
|
189
192
|
type: OutputMockType;
|
|
190
193
|
useExamples?: boolean;
|
|
194
|
+
generateEachHttpStatus?: boolean;
|
|
191
195
|
delay?: number | (() => number);
|
|
196
|
+
delayFunctionLazyExecute?: boolean;
|
|
192
197
|
baseUrl?: string;
|
|
193
198
|
locale?: keyof typeof allLocales;
|
|
194
199
|
};
|
|
@@ -208,11 +213,18 @@ type MockOptions = Omit<OverrideMockOptions, 'properties'> & {
|
|
|
208
213
|
properties: Record<string, unknown>;
|
|
209
214
|
}>;
|
|
210
215
|
};
|
|
211
|
-
type
|
|
216
|
+
type MockPropertiesObject = {
|
|
212
217
|
[key: string]: unknown;
|
|
213
|
-
}
|
|
218
|
+
};
|
|
219
|
+
type MockPropertiesObjectFn = (specs: OpenAPIObject) => MockPropertiesObject;
|
|
220
|
+
type MockProperties = MockPropertiesObject | MockPropertiesObjectFn;
|
|
221
|
+
type MockDataObject = {
|
|
214
222
|
[key: string]: unknown;
|
|
215
|
-
}
|
|
223
|
+
};
|
|
224
|
+
type MockDataObjectFn = (specs: OpenAPIObject) => MockDataObject;
|
|
225
|
+
type MockDataArray = unknown[];
|
|
226
|
+
type MockDataArrayFn = (specs: OpenAPIObject) => MockDataArray;
|
|
227
|
+
type MockData = MockDataObject | MockDataObjectFn | MockDataArray | MockDataArrayFn;
|
|
216
228
|
type OutputTransformerFn = (verb: GeneratorVerbOptions) => GeneratorVerbOptions;
|
|
217
229
|
type OutputTransformer = string | OutputTransformerFn;
|
|
218
230
|
type MutatorObject = {
|
|
@@ -257,9 +269,11 @@ type OverrideOutput = {
|
|
|
257
269
|
suffix?: string;
|
|
258
270
|
};
|
|
259
271
|
};
|
|
272
|
+
hono?: HonoOptions;
|
|
260
273
|
query?: QueryOptions;
|
|
261
274
|
swr?: SwrOptions;
|
|
262
275
|
angular?: AngularOptions;
|
|
276
|
+
zod?: ZodOptions;
|
|
263
277
|
operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
264
278
|
requestOptions?: Record<string, any> | boolean;
|
|
265
279
|
useDates?: boolean;
|
|
@@ -273,6 +287,30 @@ type OverrideOutputContentType = {
|
|
|
273
287
|
include?: string[];
|
|
274
288
|
exclude?: string[];
|
|
275
289
|
};
|
|
290
|
+
type NormalizedHonoOptions = {
|
|
291
|
+
handlers?: string;
|
|
292
|
+
};
|
|
293
|
+
type ZodOptions = {
|
|
294
|
+
strict?: {
|
|
295
|
+
param?: boolean;
|
|
296
|
+
query?: boolean;
|
|
297
|
+
header?: boolean;
|
|
298
|
+
body?: boolean;
|
|
299
|
+
response?: boolean;
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
type NormalizedZodOptions = {
|
|
303
|
+
strict: {
|
|
304
|
+
param: boolean;
|
|
305
|
+
query: boolean;
|
|
306
|
+
header: boolean;
|
|
307
|
+
body: boolean;
|
|
308
|
+
response: boolean;
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
type HonoOptions = {
|
|
312
|
+
handlers?: string;
|
|
313
|
+
};
|
|
276
314
|
type NormalizedQueryOptions = {
|
|
277
315
|
useQuery?: boolean;
|
|
278
316
|
useSuspenseQuery?: boolean;
|
|
@@ -309,9 +347,10 @@ type AngularOptions = {
|
|
|
309
347
|
provideIn?: 'root' | 'any' | boolean;
|
|
310
348
|
};
|
|
311
349
|
type SwrOptions = {
|
|
312
|
-
options?: any;
|
|
313
350
|
useInfinite?: boolean;
|
|
314
351
|
swrOptions?: any;
|
|
352
|
+
swrMutationOptions?: any;
|
|
353
|
+
swrInfiniteOptions?: any;
|
|
315
354
|
};
|
|
316
355
|
type InputTransformerFn = (spec: OpenAPIObject) => OpenAPIObject;
|
|
317
356
|
type InputTransformer = string | InputTransformerFn;
|
|
@@ -322,12 +361,13 @@ type OperationOptions = {
|
|
|
322
361
|
transformer?: OutputTransformer;
|
|
323
362
|
mutator?: Mutator;
|
|
324
363
|
mock?: {
|
|
325
|
-
data?:
|
|
364
|
+
data?: MockData;
|
|
326
365
|
properties?: MockProperties;
|
|
327
366
|
};
|
|
328
367
|
query?: QueryOptions;
|
|
329
368
|
angular?: Required<AngularOptions>;
|
|
330
369
|
swr?: SwrOptions;
|
|
370
|
+
zod?: ZodOptions;
|
|
331
371
|
operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
332
372
|
formData?: boolean | Mutator;
|
|
333
373
|
formUrlEncoded?: boolean | Mutator;
|
|
@@ -470,6 +510,8 @@ type GeneratorOperation = {
|
|
|
470
510
|
};
|
|
471
511
|
type GeneratorVerbOptions = {
|
|
472
512
|
verb: Verbs;
|
|
513
|
+
route: string;
|
|
514
|
+
pathRoute: string;
|
|
473
515
|
summary?: string;
|
|
474
516
|
doc: string;
|
|
475
517
|
tags: string[];
|
|
@@ -519,6 +561,11 @@ type GeneratorMutator = {
|
|
|
519
561
|
bodyTypeName?: string;
|
|
520
562
|
};
|
|
521
563
|
type ClientBuilder = (verbOptions: GeneratorVerbOptions, options: GeneratorOptions, outputClient: OutputClient | OutputClientFunc, output?: NormalizedOutputOptions) => GeneratorClient | Promise<GeneratorClient>;
|
|
564
|
+
type ClientFileBuilder = {
|
|
565
|
+
path: string;
|
|
566
|
+
content: string;
|
|
567
|
+
};
|
|
568
|
+
type ClientExtraFilesBuilder = (verbOptions: Record<string, GeneratorVerbOptions>, output: NormalizedOutputOptions, context: ContextSpecs) => Promise<ClientFileBuilder[]>;
|
|
522
569
|
type ClientHeaderBuilder = (params: {
|
|
523
570
|
title: string;
|
|
524
571
|
isRequestOptions: boolean;
|
|
@@ -527,6 +574,10 @@ type ClientHeaderBuilder = (params: {
|
|
|
527
574
|
isGlobalMutator: boolean;
|
|
528
575
|
provideIn: boolean | 'root' | 'any';
|
|
529
576
|
hasAwaitedType: boolean;
|
|
577
|
+
output: NormalizedOutputOptions;
|
|
578
|
+
verbOptions: Record<string, GeneratorVerbOptions>;
|
|
579
|
+
tag?: string;
|
|
580
|
+
clientImplementation: string;
|
|
530
581
|
}) => string;
|
|
531
582
|
type ClientFooterBuilder = (params: {
|
|
532
583
|
noFunction?: boolean | undefined;
|
|
@@ -547,6 +598,7 @@ interface ClientGeneratorsBuilder {
|
|
|
547
598
|
dependencies?: ClientDependenciesBuilder;
|
|
548
599
|
footer?: ClientFooterBuilder;
|
|
549
600
|
title?: ClientTitleBuilder;
|
|
601
|
+
extraFiles?: ClientExtraFilesBuilder;
|
|
550
602
|
}
|
|
551
603
|
type GeneratorClients = Record<OutputClient, ClientGeneratorsBuilder>;
|
|
552
604
|
type GetterResponse = {
|
|
@@ -573,6 +625,7 @@ type GetterBody = {
|
|
|
573
625
|
formData?: string;
|
|
574
626
|
formUrlEncoded?: string;
|
|
575
627
|
contentType: string;
|
|
628
|
+
isOptional: boolean;
|
|
576
629
|
};
|
|
577
630
|
type GetterParameters = {
|
|
578
631
|
query: {
|
|
@@ -664,11 +717,13 @@ type ResReqTypesValue = ScalarValue & {
|
|
|
664
717
|
type WriteSpecsBuilder = {
|
|
665
718
|
operations: GeneratorOperations;
|
|
666
719
|
schemas: Record<string, GeneratorSchema[]>;
|
|
720
|
+
verbOptions: Record<string, GeneratorVerbOptions>;
|
|
667
721
|
title: GeneratorClientTitle;
|
|
668
722
|
header: GeneratorClientHeader;
|
|
669
723
|
footer: GeneratorClientFooter;
|
|
670
724
|
imports: GeneratorClientImports;
|
|
671
725
|
importsMock: GenerateMockImports;
|
|
726
|
+
extraFiles: ClientFileBuilder[];
|
|
672
727
|
info: InfoObject;
|
|
673
728
|
target: string;
|
|
674
729
|
};
|
|
@@ -681,6 +736,7 @@ type WriteModeProps = {
|
|
|
681
736
|
needSchema: boolean;
|
|
682
737
|
};
|
|
683
738
|
type GeneratorApiOperations = {
|
|
739
|
+
verbOptions: Record<string, GeneratorVerbOptions>;
|
|
684
740
|
operations: GeneratorOperations;
|
|
685
741
|
schemas: GeneratorSchema[];
|
|
686
742
|
};
|
|
@@ -703,6 +759,9 @@ type GeneratorClientHeader = (data: {
|
|
|
703
759
|
hasAwaitedType: boolean;
|
|
704
760
|
titles: GeneratorClientExtra;
|
|
705
761
|
output: NormalizedOutputOptions;
|
|
762
|
+
verbOptions: Record<string, GeneratorVerbOptions>;
|
|
763
|
+
tag?: string;
|
|
764
|
+
clientImplementation: string;
|
|
706
765
|
}) => GeneratorClientExtra;
|
|
707
766
|
type GeneratorClientFooter = (data: {
|
|
708
767
|
outputClient: OutputClient | OutputClientFunc;
|
|
@@ -744,6 +803,7 @@ type GeneratorApiBuilder = GeneratorApiOperations & {
|
|
|
744
803
|
footer: GeneratorClientFooter;
|
|
745
804
|
imports: GeneratorClientImports;
|
|
746
805
|
importsMock: GenerateMockImports;
|
|
806
|
+
extraFiles: ClientFileBuilder[];
|
|
747
807
|
};
|
|
748
808
|
|
|
749
809
|
declare const generalJSTypes: string[];
|
|
@@ -854,11 +914,12 @@ declare const generateParameterDefinition: (parameters: ComponentsObject['parame
|
|
|
854
914
|
*/
|
|
855
915
|
declare const generateSchemasDefinition: (schemas: SchemasObject | undefined, context: ContextSpecs, suffix: string) => GeneratorSchema[];
|
|
856
916
|
|
|
857
|
-
declare const generateVerbsOptions: ({ verbs, input, output, route, context, }: {
|
|
917
|
+
declare const generateVerbsOptions: ({ verbs, input, output, route, pathRoute, context, }: {
|
|
858
918
|
verbs: PathItemObject;
|
|
859
919
|
input: NormalizedInputOptions;
|
|
860
920
|
output: NormalizedOutputOptions;
|
|
861
921
|
route: string;
|
|
922
|
+
pathRoute: string;
|
|
862
923
|
context: ContextSpecs;
|
|
863
924
|
}) => Promise<GeneratorVerbsOptions>;
|
|
864
925
|
declare const _filteredVerbs: (verbs: PathItemObject, filters: NormalizedInputOptions['filters']) => [string, any][];
|
|
@@ -978,7 +1039,7 @@ declare const getRefInfo: ($ref: ReferenceObject['$ref'], context: ContextSpecs)
|
|
|
978
1039
|
declare const getResReqTypes: (responsesOrRequests: Array<[
|
|
979
1040
|
string,
|
|
980
1041
|
ResponseObject | ReferenceObject | RequestBodyObject
|
|
981
|
-
]>, name: string, context: ContextSpecs, defaultType?: string) => ResReqTypesValue[];
|
|
1042
|
+
]>, name: string, context: ContextSpecs, defaultType?: string, uniqueKey?: ValueIteratee<ResReqTypesValue>) => ResReqTypesValue[];
|
|
982
1043
|
|
|
983
1044
|
declare const getResponse: ({ responses, operationName, context, contentType, }: {
|
|
984
1045
|
responses: ResponsesObject;
|
|
@@ -1060,10 +1121,20 @@ interface DebuggerOptions {
|
|
|
1060
1121
|
}
|
|
1061
1122
|
declare function createDebugger(ns: string, options?: DebuggerOptions): debug.Debugger['log'];
|
|
1062
1123
|
|
|
1063
|
-
declare function jsDoc({ description, deprecated, summary, }: {
|
|
1124
|
+
declare function jsDoc({ description, deprecated, summary, minLength, maxLength, minimum, maximum, exclusiveMinimum, exclusiveMaximum, minItems, maxItems, nullable, pattern, }: {
|
|
1064
1125
|
description?: string[] | string;
|
|
1065
1126
|
deprecated?: boolean;
|
|
1066
1127
|
summary?: string;
|
|
1128
|
+
minLength?: number;
|
|
1129
|
+
maxLength?: number;
|
|
1130
|
+
minimum?: number;
|
|
1131
|
+
maximum?: number;
|
|
1132
|
+
exclusiveMinimum?: boolean;
|
|
1133
|
+
exclusiveMaximum?: boolean;
|
|
1134
|
+
minItems?: number;
|
|
1135
|
+
maxItems?: number;
|
|
1136
|
+
nullable?: boolean;
|
|
1137
|
+
pattern?: string;
|
|
1067
1138
|
}, tryOneLine?: boolean): string;
|
|
1068
1139
|
|
|
1069
1140
|
declare const dynamicImport: <T>(toImport: string | T, from?: string, takeDefault?: boolean) => Promise<T>;
|
|
@@ -1258,4 +1329,4 @@ declare const generateTarget: (builder: WriteSpecsBuilder, options: NormalizedOu
|
|
|
1258
1329
|
|
|
1259
1330
|
declare const generateTargetForTags: (builder: WriteSpecsBuilder, options: NormalizedOutputOptions) => Record<string, GeneratorTarget>;
|
|
1260
1331
|
|
|
1261
|
-
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 HookOption, 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 SwrOptions, 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, 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, logError, 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 };
|
|
1332
|
+
export { type AngularOptions, BODY_TYPE_NAME, type ClientBuilder, type ClientDependenciesBuilder, type ClientExtraFilesBuilder, type ClientFileBuilder, 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 HonoOptions, type Hook, type HookCommand, type HookFunction, type HookOption, type HooksOptions, type ImportOpenApi, type InputOptions, type InputTransformerFn, type LogLevel, LogLevels, type LogOptions, type LogType, type Logger, type LoggerOptions, type MockData, type MockDataArray, type MockDataArrayFn, type MockDataObject, type MockDataObjectFn, type MockOptions, type MockProperties, type MockPropertiesObject, type MockPropertiesObjectFn, type Mutator, type MutatorObject, type NormalizedConfig, type NormalizedHonoOptions, type NormalizedHookCommand, type NormalizedHookOptions, type NormalizedInputOptions, type NormalizedMutator, type NormalizedOperationOptions, type NormalizedOptions, type NormalizedOutputOptions, type NormalizedOverrideOutput, type NormalizedParamsSerializerOptions, type NormalizedQueryOptions, type NormalizedZodOptions, 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 SwrOptions, type TsConfigTarget, type Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, type WriteModeProps, type WriteSpecsBuilder, type ZodOptions, _filteredVerbs, addDependency, asyncReduce, camel, combineSchemas, compareVersions, count, createDebugger, createLogger, createSuccessMessage, dynamicImport, 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, logError, 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 };
|
package/dist/index.js
CHANGED
|
@@ -39866,7 +39866,8 @@ var OutputClient = {
|
|
|
39866
39866
|
SVELTE_QUERY: "svelte-query",
|
|
39867
39867
|
VUE_QUERY: "vue-query",
|
|
39868
39868
|
SWR: "swr",
|
|
39869
|
-
ZOD: "zod"
|
|
39869
|
+
ZOD: "zod",
|
|
39870
|
+
HONO: "hono"
|
|
39870
39871
|
};
|
|
39871
39872
|
var OutputMode = {
|
|
39872
39873
|
SINGLE: "single",
|
|
@@ -40649,13 +40650,34 @@ var regex = new RegExp(search, "g");
|
|
|
40649
40650
|
function jsDoc({
|
|
40650
40651
|
description,
|
|
40651
40652
|
deprecated,
|
|
40652
|
-
summary
|
|
40653
|
+
summary,
|
|
40654
|
+
minLength,
|
|
40655
|
+
maxLength,
|
|
40656
|
+
minimum,
|
|
40657
|
+
maximum,
|
|
40658
|
+
exclusiveMinimum,
|
|
40659
|
+
exclusiveMaximum,
|
|
40660
|
+
minItems,
|
|
40661
|
+
maxItems,
|
|
40662
|
+
nullable,
|
|
40663
|
+
pattern
|
|
40653
40664
|
}, tryOneLine = false) {
|
|
40654
40665
|
const lines = (Array.isArray(description) ? description.filter((d2) => !d2.includes("eslint-disable")) : [description || ""]).map((line) => line.replace(regex, replacement));
|
|
40655
|
-
const count2 = [
|
|
40656
|
-
|
|
40657
|
-
|
|
40658
|
-
|
|
40666
|
+
const count2 = [
|
|
40667
|
+
description,
|
|
40668
|
+
deprecated,
|
|
40669
|
+
summary,
|
|
40670
|
+
minLength?.toString(),
|
|
40671
|
+
maxLength?.toString(),
|
|
40672
|
+
minimum?.toString(),
|
|
40673
|
+
maximum?.toString(),
|
|
40674
|
+
exclusiveMinimum?.toString(),
|
|
40675
|
+
exclusiveMaximum?.toString(),
|
|
40676
|
+
minItems?.toString(),
|
|
40677
|
+
maxItems?.toString(),
|
|
40678
|
+
nullable?.toString(),
|
|
40679
|
+
pattern
|
|
40680
|
+
].reduce((acc, it) => it ? acc + 1 : acc, 0);
|
|
40659
40681
|
if (!count2) {
|
|
40660
40682
|
return "";
|
|
40661
40683
|
}
|
|
@@ -40670,20 +40692,42 @@ ${tryOneLine ? " " : ""} *`;
|
|
|
40670
40692
|
}
|
|
40671
40693
|
doc += ` ${lines.join("\n * ")}`;
|
|
40672
40694
|
}
|
|
40673
|
-
|
|
40695
|
+
function appendPrefix() {
|
|
40674
40696
|
if (!oneLine) {
|
|
40675
40697
|
doc += `
|
|
40676
40698
|
${tryOneLine ? " " : ""} *`;
|
|
40677
40699
|
}
|
|
40678
|
-
doc += " @deprecated";
|
|
40679
40700
|
}
|
|
40680
|
-
|
|
40681
|
-
if (
|
|
40682
|
-
|
|
40683
|
-
|
|
40701
|
+
function tryAppendStringDocLine(key, value) {
|
|
40702
|
+
if (value) {
|
|
40703
|
+
appendPrefix();
|
|
40704
|
+
doc += ` @${key} ${value}`;
|
|
40705
|
+
}
|
|
40706
|
+
}
|
|
40707
|
+
function tryAppendBooleanDocLine(key, value) {
|
|
40708
|
+
if (value === true) {
|
|
40709
|
+
appendPrefix();
|
|
40710
|
+
doc += ` @${key}`;
|
|
40684
40711
|
}
|
|
40685
|
-
doc += ` @summary ${summary.replace(regex, replacement)}`;
|
|
40686
40712
|
}
|
|
40713
|
+
function tryAppendNumberDocLine(key, value) {
|
|
40714
|
+
if (value !== void 0) {
|
|
40715
|
+
appendPrefix();
|
|
40716
|
+
doc += ` @${key} ${value}`;
|
|
40717
|
+
}
|
|
40718
|
+
}
|
|
40719
|
+
tryAppendBooleanDocLine("deprecated", deprecated);
|
|
40720
|
+
tryAppendStringDocLine("summary", summary?.replace(regex, replacement));
|
|
40721
|
+
tryAppendNumberDocLine("minLength", minLength);
|
|
40722
|
+
tryAppendNumberDocLine("maxLength", maxLength);
|
|
40723
|
+
tryAppendNumberDocLine("minimum", minimum);
|
|
40724
|
+
tryAppendNumberDocLine("maximum", maximum);
|
|
40725
|
+
tryAppendBooleanDocLine("exclusiveMinimum", exclusiveMinimum);
|
|
40726
|
+
tryAppendBooleanDocLine("exclusiveMaximum", exclusiveMaximum);
|
|
40727
|
+
tryAppendNumberDocLine("minItems", minItems);
|
|
40728
|
+
tryAppendNumberDocLine("maxItems", maxItems);
|
|
40729
|
+
tryAppendBooleanDocLine("nullable", nullable);
|
|
40730
|
+
tryAppendStringDocLine("pattern", pattern);
|
|
40687
40731
|
doc += !oneLine ? `
|
|
40688
40732
|
${tryOneLine ? " " : ""}` : " ";
|
|
40689
40733
|
doc += "*/\n";
|
|
@@ -40927,10 +40971,10 @@ var ibmOpenapiValidator = async (specs) => {
|
|
|
40927
40971
|
const spectral = new Spectral();
|
|
40928
40972
|
spectral.setRuleset(ibmOpenapiRuleset);
|
|
40929
40973
|
const { errors, warnings } = await spectral.run(specs);
|
|
40930
|
-
if (warnings.length) {
|
|
40974
|
+
if (warnings && warnings.length) {
|
|
40931
40975
|
ibmOpenapiValidatorWarnings(warnings);
|
|
40932
40976
|
}
|
|
40933
|
-
if (errors.length) {
|
|
40977
|
+
if (errors && errors.length) {
|
|
40934
40978
|
ibmOpenapiValidatorErrors(errors);
|
|
40935
40979
|
}
|
|
40936
40980
|
};
|
|
@@ -41372,7 +41416,7 @@ var getResReqContentTypes = ({
|
|
|
41372
41416
|
});
|
|
41373
41417
|
return resolvedObject;
|
|
41374
41418
|
};
|
|
41375
|
-
var getResReqTypes = (responsesOrRequests, name, context, defaultType = "unknown") => {
|
|
41419
|
+
var getResReqTypes = (responsesOrRequests, name, context, defaultType = "unknown", uniqueKey = "value") => {
|
|
41376
41420
|
const typesArray = responsesOrRequests.filter(([_2, res]) => Boolean(res)).map(([key, res]) => {
|
|
41377
41421
|
if (isReference(res)) {
|
|
41378
41422
|
const {
|
|
@@ -41504,7 +41548,7 @@ var getResReqTypes = (responsesOrRequests, name, context, defaultType = "unknown
|
|
|
41504
41548
|
});
|
|
41505
41549
|
return (0, import_lodash5.default)(
|
|
41506
41550
|
typesArray.flatMap((it) => it),
|
|
41507
|
-
|
|
41551
|
+
uniqueKey
|
|
41508
41552
|
);
|
|
41509
41553
|
};
|
|
41510
41554
|
var getSchemaFormDataAndUrlEncoded = ({
|
|
@@ -41555,7 +41599,7 @@ var getSchemaFormDataAndUrlEncoded = ({
|
|
|
41555
41599
|
return `${form}${propName}.forEach(value => ${variableName}.append('data', value))
|
|
41556
41600
|
`;
|
|
41557
41601
|
}
|
|
41558
|
-
if (schema.type === "number" || schema.type === "boolean") {
|
|
41602
|
+
if (schema.type === "number" || schema.type === "integer" || schema.type === "boolean") {
|
|
41559
41603
|
return `${form}${variableName}.append('data', ${propName}.toString())
|
|
41560
41604
|
`;
|
|
41561
41605
|
}
|
|
@@ -41639,6 +41683,7 @@ var getBody = ({
|
|
|
41639
41683
|
const hasReadonlyProps = filteredBodyTypes.some((x3) => x3.hasReadonlyProps);
|
|
41640
41684
|
const nonReadonlyDefinition = hasReadonlyProps && definition ? `NonReadonly<${definition}>` : definition;
|
|
41641
41685
|
let implementation = generalJSTypesWithArray.includes(definition.toLowerCase()) || filteredBodyTypes.length > 1 ? camel(operationName) + context.output.override.components.requestBodies.suffix : camel(definition);
|
|
41686
|
+
let isOptional = false;
|
|
41642
41687
|
if (implementation) {
|
|
41643
41688
|
implementation = sanitize(implementation, {
|
|
41644
41689
|
underscore: "_",
|
|
@@ -41647,6 +41692,17 @@ var getBody = ({
|
|
|
41647
41692
|
es5keyword: true,
|
|
41648
41693
|
es5IdentifierName: true
|
|
41649
41694
|
});
|
|
41695
|
+
if (isReference(requestBody)) {
|
|
41696
|
+
const { schema: bodySchema } = resolveRef(
|
|
41697
|
+
requestBody,
|
|
41698
|
+
context
|
|
41699
|
+
);
|
|
41700
|
+
if (bodySchema.required !== void 0) {
|
|
41701
|
+
isOptional = !bodySchema.required;
|
|
41702
|
+
}
|
|
41703
|
+
} else if (requestBody.required !== void 0) {
|
|
41704
|
+
isOptional = !requestBody.required;
|
|
41705
|
+
}
|
|
41650
41706
|
}
|
|
41651
41707
|
return {
|
|
41652
41708
|
originalSchema: requestBody,
|
|
@@ -41654,6 +41710,7 @@ var getBody = ({
|
|
|
41654
41710
|
implementation,
|
|
41655
41711
|
imports,
|
|
41656
41712
|
schemas,
|
|
41713
|
+
isOptional,
|
|
41657
41714
|
...filteredBodyTypes.length === 1 ? {
|
|
41658
41715
|
formData: filteredBodyTypes[0].formData,
|
|
41659
41716
|
formUrlEncoded: filteredBodyTypes[0].formUrlEncoded,
|
|
@@ -41831,10 +41888,8 @@ var getObject = ({
|
|
|
41831
41888
|
hasReadonlyProps: item.readOnly || false
|
|
41832
41889
|
};
|
|
41833
41890
|
}
|
|
41834
|
-
const useTypeOverInterfaces = context?.output.override?.useTypeOverInterfaces;
|
|
41835
|
-
const blankValue = item.type === "object" ? "{ [key: string]: any }" : useTypeOverInterfaces ? "unknown" : "{}";
|
|
41836
41891
|
return {
|
|
41837
|
-
value:
|
|
41892
|
+
value: (item.type === "object" ? "{ [key: string]: any }" : "unknown") + nullable,
|
|
41838
41893
|
imports: [],
|
|
41839
41894
|
schemas: [],
|
|
41840
41895
|
isEnum: false,
|
|
@@ -42294,10 +42349,10 @@ var getProps = ({
|
|
|
42294
42349
|
}) => {
|
|
42295
42350
|
const bodyProp = {
|
|
42296
42351
|
name: body.implementation,
|
|
42297
|
-
definition: `${body.implementation}: ${body.definition}`,
|
|
42298
|
-
implementation: `${body.implementation}: ${body.definition}`,
|
|
42352
|
+
definition: `${body.implementation}${body.isOptional ? "?" : ""}: ${body.definition}`,
|
|
42353
|
+
implementation: `${body.implementation}${body.isOptional ? "?" : ""}: ${body.definition}`,
|
|
42299
42354
|
default: false,
|
|
42300
|
-
required:
|
|
42355
|
+
required: !body.isOptional,
|
|
42301
42356
|
type: GetterPropType.BODY
|
|
42302
42357
|
};
|
|
42303
42358
|
const queryParamsProp = {
|
|
@@ -42473,7 +42528,8 @@ var getResponse = ({
|
|
|
42473
42528
|
Object.entries(responses),
|
|
42474
42529
|
operationName,
|
|
42475
42530
|
context,
|
|
42476
|
-
"void"
|
|
42531
|
+
"void",
|
|
42532
|
+
(type) => type.key.startsWith("2") + type.value
|
|
42477
42533
|
);
|
|
42478
42534
|
const filteredTypes = contentType ? types.filter((type) => {
|
|
42479
42535
|
let include = true;
|
|
@@ -43302,7 +43358,8 @@ var generateInterface = ({
|
|
|
43302
43358
|
}
|
|
43303
43359
|
}
|
|
43304
43360
|
if (scalar.type === "object" && !context?.output.override?.useTypeOverInterfaces) {
|
|
43305
|
-
|
|
43361
|
+
const blankInterfaceValue = scalar.value === "unknown" ? "{}" : scalar.value;
|
|
43362
|
+
model += `export interface ${name} ${blankInterfaceValue}
|
|
43306
43363
|
`;
|
|
43307
43364
|
} else {
|
|
43308
43365
|
model += `export type ${name} = ${scalar.value};
|
|
@@ -43406,6 +43463,7 @@ var generateVerbOptions = async ({
|
|
|
43406
43463
|
output,
|
|
43407
43464
|
operation,
|
|
43408
43465
|
route,
|
|
43466
|
+
pathRoute,
|
|
43409
43467
|
verbParameters = [],
|
|
43410
43468
|
context
|
|
43411
43469
|
}) => {
|
|
@@ -43506,6 +43564,8 @@ var generateVerbOptions = async ({
|
|
|
43506
43564
|
const verbOption = {
|
|
43507
43565
|
verb,
|
|
43508
43566
|
tags,
|
|
43567
|
+
route,
|
|
43568
|
+
pathRoute,
|
|
43509
43569
|
summary: operation.summary,
|
|
43510
43570
|
operationId,
|
|
43511
43571
|
operationName,
|
|
@@ -43535,6 +43595,7 @@ var generateVerbsOptions = ({
|
|
|
43535
43595
|
input,
|
|
43536
43596
|
output,
|
|
43537
43597
|
route,
|
|
43598
|
+
pathRoute,
|
|
43538
43599
|
context
|
|
43539
43600
|
}) => asyncReduce(
|
|
43540
43601
|
_filteredVerbs(verbs, input.filters),
|
|
@@ -43545,6 +43606,7 @@ var generateVerbsOptions = ({
|
|
|
43545
43606
|
output,
|
|
43546
43607
|
verbParameters: verbs.parameters,
|
|
43547
43608
|
route,
|
|
43609
|
+
pathRoute,
|
|
43548
43610
|
operation,
|
|
43549
43611
|
context
|
|
43550
43612
|
});
|
|
@@ -43680,31 +43742,32 @@ ${exports2}`;
|
|
|
43680
43742
|
|
|
43681
43743
|
// src/writers/types.ts
|
|
43682
43744
|
var getOrvalGeneratedTypes = () => `
|
|
43683
|
-
|
|
43684
|
-
type
|
|
43685
|
-
|
|
43686
|
-
|
|
43687
|
-
|
|
43688
|
-
|
|
43689
|
-
|
|
43690
|
-
|
|
43691
|
-
|
|
43692
|
-
|
|
43693
|
-
|
|
43694
|
-
|
|
43695
|
-
|
|
43696
|
-
|
|
43697
|
-
|
|
43698
|
-
|
|
43699
|
-
|
|
43700
|
-
|
|
43701
|
-
|
|
43702
|
-
|
|
43703
|
-
|
|
43704
|
-
|
|
43705
|
-
|
|
43706
|
-
|
|
43707
|
-
|
|
43745
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
43746
|
+
type IsUnknown<T> = IsAny<T> extends true ? false : unknown extends T ? true : false;
|
|
43747
|
+
type Primitive = string | number | boolean | bigint | symbol | undefined | null;
|
|
43748
|
+
type isBuiltin = Primitive | Function | Date | Error | RegExp;
|
|
43749
|
+
type NonReadonly<T> =
|
|
43750
|
+
T extends Exclude<isBuiltin, Error>
|
|
43751
|
+
? T
|
|
43752
|
+
: T extends Map<infer Key, infer Value>
|
|
43753
|
+
? Map<NonReadonly<Key>, NonReadonly<Value>>
|
|
43754
|
+
: T extends ReadonlyMap<infer Key, infer Value>
|
|
43755
|
+
? Map<NonReadonly<Key>, NonReadonly<Value>>
|
|
43756
|
+
: T extends WeakMap<infer Key, infer Value>
|
|
43757
|
+
? WeakMap<NonReadonly<Key>, NonReadonly<Value>>
|
|
43758
|
+
: T extends Set<infer Values>
|
|
43759
|
+
? Set<NonReadonly<Values>>
|
|
43760
|
+
: T extends ReadonlySet<infer Values>
|
|
43761
|
+
? Set<NonReadonly<Values>>
|
|
43762
|
+
: T extends WeakSet<infer Values>
|
|
43763
|
+
? WeakSet<NonReadonly<Values>>
|
|
43764
|
+
: T extends Promise<infer Value>
|
|
43765
|
+
? Promise<NonReadonly<Value>>
|
|
43766
|
+
: T extends {}
|
|
43767
|
+
? { -readonly [Key in keyof T]: NonReadonly<T[Key]> }
|
|
43768
|
+
: IsUnknown<T> extends true
|
|
43769
|
+
? unknown
|
|
43770
|
+
: T;
|
|
43708
43771
|
`;
|
|
43709
43772
|
|
|
43710
43773
|
// src/writers/single-mode.ts
|
|
@@ -43760,7 +43823,9 @@ var generateTarget = (builder, options) => {
|
|
|
43760
43823
|
provideIn: options.override.angular.provideIn,
|
|
43761
43824
|
hasAwaitedType,
|
|
43762
43825
|
titles,
|
|
43763
|
-
output: options
|
|
43826
|
+
output: options,
|
|
43827
|
+
verbOptions: builder.verbOptions,
|
|
43828
|
+
clientImplementation: acc.implementation
|
|
43764
43829
|
});
|
|
43765
43830
|
acc.implementation = header.implementation + acc.implementation;
|
|
43766
43831
|
acc.implementationMock.handler = acc.implementationMock.handler + header.implementationMock + acc.implementationMock.handlerName;
|
|
@@ -44092,7 +44157,10 @@ var generateTargetForTags = (builder, options) => {
|
|
|
44092
44157
|
provideIn: options.override.angular.provideIn,
|
|
44093
44158
|
hasAwaitedType,
|
|
44094
44159
|
titles,
|
|
44095
|
-
output: options
|
|
44160
|
+
output: options,
|
|
44161
|
+
verbOptions: builder.verbOptions,
|
|
44162
|
+
tag,
|
|
44163
|
+
clientImplementation: target.implementation
|
|
44096
44164
|
});
|
|
44097
44165
|
acc2[tag] = {
|
|
44098
44166
|
implementation: header.implementation + target.implementation + footer.implementation,
|