@orval/core 6.24.0 → 6.26.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 +61 -13
- package/dist/index.js +126 -53
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
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,6 +82,7 @@ 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;
|
|
@@ -104,15 +106,13 @@ type NormalizedOperationOptions = {
|
|
|
104
106
|
transformer?: OutputTransformer;
|
|
105
107
|
mutator?: NormalizedMutator;
|
|
106
108
|
mock?: {
|
|
107
|
-
data?:
|
|
109
|
+
data?: MockData;
|
|
108
110
|
properties?: MockProperties;
|
|
109
111
|
};
|
|
110
112
|
contentType?: OverrideOutputContentType;
|
|
111
113
|
query?: NormalizedQueryOptions;
|
|
112
114
|
angular?: Required<AngularOptions>;
|
|
113
|
-
swr?:
|
|
114
|
-
options?: any;
|
|
115
|
-
};
|
|
115
|
+
swr?: SwrOptions;
|
|
116
116
|
operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
|
|
117
117
|
formData?: boolean | NormalizedMutator;
|
|
118
118
|
formUrlEncoded?: boolean | NormalizedMutator;
|
|
@@ -172,6 +172,7 @@ declare const OutputClient: {
|
|
|
172
172
|
readonly VUE_QUERY: "vue-query";
|
|
173
173
|
readonly SWR: "swr";
|
|
174
174
|
readonly ZOD: "zod";
|
|
175
|
+
readonly HONO: "hono";
|
|
175
176
|
};
|
|
176
177
|
type OutputClient = (typeof OutputClient)[keyof typeof OutputClient];
|
|
177
178
|
declare const OutputMode: {
|
|
@@ -208,11 +209,18 @@ type MockOptions = Omit<OverrideMockOptions, 'properties'> & {
|
|
|
208
209
|
properties: Record<string, unknown>;
|
|
209
210
|
}>;
|
|
210
211
|
};
|
|
211
|
-
type
|
|
212
|
+
type MockPropertiesObject = {
|
|
212
213
|
[key: string]: unknown;
|
|
213
|
-
}
|
|
214
|
+
};
|
|
215
|
+
type MockPropertiesObjectFn = (specs: OpenAPIObject) => MockPropertiesObject;
|
|
216
|
+
type MockProperties = MockPropertiesObject | MockPropertiesObjectFn;
|
|
217
|
+
type MockDataObject = {
|
|
214
218
|
[key: string]: unknown;
|
|
215
|
-
}
|
|
219
|
+
};
|
|
220
|
+
type MockDataObjectFn = (specs: OpenAPIObject) => MockDataObject;
|
|
221
|
+
type MockDataArray = unknown[];
|
|
222
|
+
type MockDataArrayFn = (specs: OpenAPIObject) => MockDataArray;
|
|
223
|
+
type MockData = MockDataObject | MockDataObjectFn | MockDataArray | MockDataArrayFn;
|
|
216
224
|
type OutputTransformerFn = (verb: GeneratorVerbOptions) => GeneratorVerbOptions;
|
|
217
225
|
type OutputTransformer = string | OutputTransformerFn;
|
|
218
226
|
type MutatorObject = {
|
|
@@ -257,6 +265,7 @@ type OverrideOutput = {
|
|
|
257
265
|
suffix?: string;
|
|
258
266
|
};
|
|
259
267
|
};
|
|
268
|
+
hono?: HonoOptions;
|
|
260
269
|
query?: QueryOptions;
|
|
261
270
|
swr?: SwrOptions;
|
|
262
271
|
angular?: AngularOptions;
|
|
@@ -273,6 +282,12 @@ type OverrideOutputContentType = {
|
|
|
273
282
|
include?: string[];
|
|
274
283
|
exclude?: string[];
|
|
275
284
|
};
|
|
285
|
+
type NormalizedHonoOptions = {
|
|
286
|
+
handlers?: string;
|
|
287
|
+
};
|
|
288
|
+
type HonoOptions = {
|
|
289
|
+
handlers?: string;
|
|
290
|
+
};
|
|
276
291
|
type NormalizedQueryOptions = {
|
|
277
292
|
useQuery?: boolean;
|
|
278
293
|
useSuspenseQuery?: boolean;
|
|
@@ -309,8 +324,10 @@ type AngularOptions = {
|
|
|
309
324
|
provideIn?: 'root' | 'any' | boolean;
|
|
310
325
|
};
|
|
311
326
|
type SwrOptions = {
|
|
312
|
-
options?: any;
|
|
313
327
|
useInfinite?: boolean;
|
|
328
|
+
swrOptions?: any;
|
|
329
|
+
swrMutationOptions?: any;
|
|
330
|
+
swrInfiniteOptions?: any;
|
|
314
331
|
};
|
|
315
332
|
type InputTransformerFn = (spec: OpenAPIObject) => OpenAPIObject;
|
|
316
333
|
type InputTransformer = string | InputTransformerFn;
|
|
@@ -321,7 +338,7 @@ type OperationOptions = {
|
|
|
321
338
|
transformer?: OutputTransformer;
|
|
322
339
|
mutator?: Mutator;
|
|
323
340
|
mock?: {
|
|
324
|
-
data?:
|
|
341
|
+
data?: MockData;
|
|
325
342
|
properties?: MockProperties;
|
|
326
343
|
};
|
|
327
344
|
query?: QueryOptions;
|
|
@@ -469,6 +486,8 @@ type GeneratorOperation = {
|
|
|
469
486
|
};
|
|
470
487
|
type GeneratorVerbOptions = {
|
|
471
488
|
verb: Verbs;
|
|
489
|
+
route: string;
|
|
490
|
+
pathRoute: string;
|
|
472
491
|
summary?: string;
|
|
473
492
|
doc: string;
|
|
474
493
|
tags: string[];
|
|
@@ -518,6 +537,11 @@ type GeneratorMutator = {
|
|
|
518
537
|
bodyTypeName?: string;
|
|
519
538
|
};
|
|
520
539
|
type ClientBuilder = (verbOptions: GeneratorVerbOptions, options: GeneratorOptions, outputClient: OutputClient | OutputClientFunc, output?: NormalizedOutputOptions) => GeneratorClient | Promise<GeneratorClient>;
|
|
540
|
+
type ClientFileBuilder = {
|
|
541
|
+
path: string;
|
|
542
|
+
content: string;
|
|
543
|
+
};
|
|
544
|
+
type ClientExtraFilesBuilder = (verbOptions: Record<string, GeneratorVerbOptions>, output: NormalizedOutputOptions, context: ContextSpecs) => Promise<ClientFileBuilder[]>;
|
|
521
545
|
type ClientHeaderBuilder = (params: {
|
|
522
546
|
title: string;
|
|
523
547
|
isRequestOptions: boolean;
|
|
@@ -526,6 +550,10 @@ type ClientHeaderBuilder = (params: {
|
|
|
526
550
|
isGlobalMutator: boolean;
|
|
527
551
|
provideIn: boolean | 'root' | 'any';
|
|
528
552
|
hasAwaitedType: boolean;
|
|
553
|
+
output: NormalizedOutputOptions;
|
|
554
|
+
verbOptions: Record<string, GeneratorVerbOptions>;
|
|
555
|
+
tag?: string;
|
|
556
|
+
clientImplementation: string;
|
|
529
557
|
}) => string;
|
|
530
558
|
type ClientFooterBuilder = (params: {
|
|
531
559
|
noFunction?: boolean | undefined;
|
|
@@ -546,6 +574,7 @@ interface ClientGeneratorsBuilder {
|
|
|
546
574
|
dependencies?: ClientDependenciesBuilder;
|
|
547
575
|
footer?: ClientFooterBuilder;
|
|
548
576
|
title?: ClientTitleBuilder;
|
|
577
|
+
extraFiles?: ClientExtraFilesBuilder;
|
|
549
578
|
}
|
|
550
579
|
type GeneratorClients = Record<OutputClient, ClientGeneratorsBuilder>;
|
|
551
580
|
type GetterResponse = {
|
|
@@ -572,6 +601,7 @@ type GetterBody = {
|
|
|
572
601
|
formData?: string;
|
|
573
602
|
formUrlEncoded?: string;
|
|
574
603
|
contentType: string;
|
|
604
|
+
isOptional: boolean;
|
|
575
605
|
};
|
|
576
606
|
type GetterParameters = {
|
|
577
607
|
query: {
|
|
@@ -663,11 +693,13 @@ type ResReqTypesValue = ScalarValue & {
|
|
|
663
693
|
type WriteSpecsBuilder = {
|
|
664
694
|
operations: GeneratorOperations;
|
|
665
695
|
schemas: Record<string, GeneratorSchema[]>;
|
|
696
|
+
verbOptions: Record<string, GeneratorVerbOptions>;
|
|
666
697
|
title: GeneratorClientTitle;
|
|
667
698
|
header: GeneratorClientHeader;
|
|
668
699
|
footer: GeneratorClientFooter;
|
|
669
700
|
imports: GeneratorClientImports;
|
|
670
701
|
importsMock: GenerateMockImports;
|
|
702
|
+
extraFiles: ClientFileBuilder[];
|
|
671
703
|
info: InfoObject;
|
|
672
704
|
target: string;
|
|
673
705
|
};
|
|
@@ -680,6 +712,7 @@ type WriteModeProps = {
|
|
|
680
712
|
needSchema: boolean;
|
|
681
713
|
};
|
|
682
714
|
type GeneratorApiOperations = {
|
|
715
|
+
verbOptions: Record<string, GeneratorVerbOptions>;
|
|
683
716
|
operations: GeneratorOperations;
|
|
684
717
|
schemas: GeneratorSchema[];
|
|
685
718
|
};
|
|
@@ -702,6 +735,9 @@ type GeneratorClientHeader = (data: {
|
|
|
702
735
|
hasAwaitedType: boolean;
|
|
703
736
|
titles: GeneratorClientExtra;
|
|
704
737
|
output: NormalizedOutputOptions;
|
|
738
|
+
verbOptions: Record<string, GeneratorVerbOptions>;
|
|
739
|
+
tag?: string;
|
|
740
|
+
clientImplementation: string;
|
|
705
741
|
}) => GeneratorClientExtra;
|
|
706
742
|
type GeneratorClientFooter = (data: {
|
|
707
743
|
outputClient: OutputClient | OutputClientFunc;
|
|
@@ -743,6 +779,7 @@ type GeneratorApiBuilder = GeneratorApiOperations & {
|
|
|
743
779
|
footer: GeneratorClientFooter;
|
|
744
780
|
imports: GeneratorClientImports;
|
|
745
781
|
importsMock: GenerateMockImports;
|
|
782
|
+
extraFiles: ClientFileBuilder[];
|
|
746
783
|
};
|
|
747
784
|
|
|
748
785
|
declare const generalJSTypes: string[];
|
|
@@ -853,11 +890,12 @@ declare const generateParameterDefinition: (parameters: ComponentsObject['parame
|
|
|
853
890
|
*/
|
|
854
891
|
declare const generateSchemasDefinition: (schemas: SchemasObject | undefined, context: ContextSpecs, suffix: string) => GeneratorSchema[];
|
|
855
892
|
|
|
856
|
-
declare const generateVerbsOptions: ({ verbs, input, output, route, context, }: {
|
|
893
|
+
declare const generateVerbsOptions: ({ verbs, input, output, route, pathRoute, context, }: {
|
|
857
894
|
verbs: PathItemObject;
|
|
858
895
|
input: NormalizedInputOptions;
|
|
859
896
|
output: NormalizedOutputOptions;
|
|
860
897
|
route: string;
|
|
898
|
+
pathRoute: string;
|
|
861
899
|
context: ContextSpecs;
|
|
862
900
|
}) => Promise<GeneratorVerbsOptions>;
|
|
863
901
|
declare const _filteredVerbs: (verbs: PathItemObject, filters: NormalizedInputOptions['filters']) => [string, any][];
|
|
@@ -977,7 +1015,7 @@ declare const getRefInfo: ($ref: ReferenceObject['$ref'], context: ContextSpecs)
|
|
|
977
1015
|
declare const getResReqTypes: (responsesOrRequests: Array<[
|
|
978
1016
|
string,
|
|
979
1017
|
ResponseObject | ReferenceObject | RequestBodyObject
|
|
980
|
-
]>, name: string, context: ContextSpecs, defaultType?: string) => ResReqTypesValue[];
|
|
1018
|
+
]>, name: string, context: ContextSpecs, defaultType?: string, uniqueKey?: ValueIteratee<ResReqTypesValue>) => ResReqTypesValue[];
|
|
981
1019
|
|
|
982
1020
|
declare const getResponse: ({ responses, operationName, context, contentType, }: {
|
|
983
1021
|
responses: ResponsesObject;
|
|
@@ -1059,10 +1097,20 @@ interface DebuggerOptions {
|
|
|
1059
1097
|
}
|
|
1060
1098
|
declare function createDebugger(ns: string, options?: DebuggerOptions): debug.Debugger['log'];
|
|
1061
1099
|
|
|
1062
|
-
declare function jsDoc({ description, deprecated, summary, }: {
|
|
1100
|
+
declare function jsDoc({ description, deprecated, summary, minLength, maxLength, minimum, maximum, exclusiveMinimum, exclusiveMaximum, minItems, maxItems, nullable, pattern, }: {
|
|
1063
1101
|
description?: string[] | string;
|
|
1064
1102
|
deprecated?: boolean;
|
|
1065
1103
|
summary?: string;
|
|
1104
|
+
minLength?: number;
|
|
1105
|
+
maxLength?: number;
|
|
1106
|
+
minimum?: number;
|
|
1107
|
+
maximum?: number;
|
|
1108
|
+
exclusiveMinimum?: boolean;
|
|
1109
|
+
exclusiveMaximum?: boolean;
|
|
1110
|
+
minItems?: number;
|
|
1111
|
+
maxItems?: number;
|
|
1112
|
+
nullable?: boolean;
|
|
1113
|
+
pattern?: string;
|
|
1066
1114
|
}, tryOneLine?: boolean): string;
|
|
1067
1115
|
|
|
1068
1116
|
declare const dynamicImport: <T>(toImport: string | T, from?: string, takeDefault?: boolean) => Promise<T>;
|
|
@@ -1257,4 +1305,4 @@ declare const generateTarget: (builder: WriteSpecsBuilder, options: NormalizedOu
|
|
|
1257
1305
|
|
|
1258
1306
|
declare const generateTargetForTags: (builder: WriteSpecsBuilder, options: NormalizedOutputOptions) => Record<string, GeneratorTarget>;
|
|
1259
1307
|
|
|
1260
|
-
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 };
|
|
1308
|
+
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 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 };
|
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}`;
|
|
40711
|
+
}
|
|
40712
|
+
}
|
|
40713
|
+
function tryAppendNumberDocLine(key, value) {
|
|
40714
|
+
if (value !== void 0) {
|
|
40715
|
+
appendPrefix();
|
|
40716
|
+
doc += ` @${key} ${value}`;
|
|
40684
40717
|
}
|
|
40685
|
-
doc += ` @summary ${summary.replace(regex, replacement)}`;
|
|
40686
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 = ({
|
|
@@ -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,
|
|
@@ -41848,7 +41905,8 @@ var getScalar = ({
|
|
|
41848
41905
|
name,
|
|
41849
41906
|
context
|
|
41850
41907
|
}) => {
|
|
41851
|
-
const
|
|
41908
|
+
const isAngularClient = context.output.client === OutputClient.ANGULAR;
|
|
41909
|
+
const nullable = item.nullable && !isAngularClient ? " | null" : "";
|
|
41852
41910
|
const enumItems = item.enum?.filter((enumItem) => enumItem !== null);
|
|
41853
41911
|
if (!item.type && item.items) {
|
|
41854
41912
|
item.type = "array";
|
|
@@ -42291,10 +42349,10 @@ var getProps = ({
|
|
|
42291
42349
|
}) => {
|
|
42292
42350
|
const bodyProp = {
|
|
42293
42351
|
name: body.implementation,
|
|
42294
|
-
definition: `${body.implementation}: ${body.definition}`,
|
|
42295
|
-
implementation: `${body.implementation}: ${body.definition}`,
|
|
42352
|
+
definition: `${body.implementation}${body.isOptional ? "?" : ""}: ${body.definition}`,
|
|
42353
|
+
implementation: `${body.implementation}${body.isOptional ? "?" : ""}: ${body.definition}`,
|
|
42296
42354
|
default: false,
|
|
42297
|
-
required:
|
|
42355
|
+
required: !body.isOptional,
|
|
42298
42356
|
type: GetterPropType.BODY
|
|
42299
42357
|
};
|
|
42300
42358
|
const queryParamsProp = {
|
|
@@ -42470,7 +42528,8 @@ var getResponse = ({
|
|
|
42470
42528
|
Object.entries(responses),
|
|
42471
42529
|
operationName,
|
|
42472
42530
|
context,
|
|
42473
|
-
"void"
|
|
42531
|
+
"void",
|
|
42532
|
+
(type) => type.key.startsWith("2") + type.value
|
|
42474
42533
|
);
|
|
42475
42534
|
const filteredTypes = contentType ? types.filter((type) => {
|
|
42476
42535
|
let include = true;
|
|
@@ -43299,7 +43358,8 @@ var generateInterface = ({
|
|
|
43299
43358
|
}
|
|
43300
43359
|
}
|
|
43301
43360
|
if (scalar.type === "object" && !context?.output.override?.useTypeOverInterfaces) {
|
|
43302
|
-
|
|
43361
|
+
const blankInterfaceValue = scalar.value === "unknown" ? "{}" : scalar.value;
|
|
43362
|
+
model += `export interface ${name} ${blankInterfaceValue}
|
|
43303
43363
|
`;
|
|
43304
43364
|
} else {
|
|
43305
43365
|
model += `export type ${name} = ${scalar.value};
|
|
@@ -43403,6 +43463,7 @@ var generateVerbOptions = async ({
|
|
|
43403
43463
|
output,
|
|
43404
43464
|
operation,
|
|
43405
43465
|
route,
|
|
43466
|
+
pathRoute,
|
|
43406
43467
|
verbParameters = [],
|
|
43407
43468
|
context
|
|
43408
43469
|
}) => {
|
|
@@ -43503,6 +43564,8 @@ var generateVerbOptions = async ({
|
|
|
43503
43564
|
const verbOption = {
|
|
43504
43565
|
verb,
|
|
43505
43566
|
tags,
|
|
43567
|
+
route,
|
|
43568
|
+
pathRoute,
|
|
43506
43569
|
summary: operation.summary,
|
|
43507
43570
|
operationId,
|
|
43508
43571
|
operationName,
|
|
@@ -43532,6 +43595,7 @@ var generateVerbsOptions = ({
|
|
|
43532
43595
|
input,
|
|
43533
43596
|
output,
|
|
43534
43597
|
route,
|
|
43598
|
+
pathRoute,
|
|
43535
43599
|
context
|
|
43536
43600
|
}) => asyncReduce(
|
|
43537
43601
|
_filteredVerbs(verbs, input.filters),
|
|
@@ -43542,6 +43606,7 @@ var generateVerbsOptions = ({
|
|
|
43542
43606
|
output,
|
|
43543
43607
|
verbParameters: verbs.parameters,
|
|
43544
43608
|
route,
|
|
43609
|
+
pathRoute,
|
|
43545
43610
|
operation,
|
|
43546
43611
|
context
|
|
43547
43612
|
});
|
|
@@ -43677,31 +43742,32 @@ ${exports2}`;
|
|
|
43677
43742
|
|
|
43678
43743
|
// src/writers/types.ts
|
|
43679
43744
|
var getOrvalGeneratedTypes = () => `
|
|
43680
|
-
|
|
43681
|
-
type
|
|
43682
|
-
|
|
43683
|
-
|
|
43684
|
-
|
|
43685
|
-
|
|
43686
|
-
|
|
43687
|
-
|
|
43688
|
-
|
|
43689
|
-
|
|
43690
|
-
|
|
43691
|
-
|
|
43692
|
-
|
|
43693
|
-
|
|
43694
|
-
|
|
43695
|
-
|
|
43696
|
-
|
|
43697
|
-
|
|
43698
|
-
|
|
43699
|
-
|
|
43700
|
-
|
|
43701
|
-
|
|
43702
|
-
|
|
43703
|
-
|
|
43704
|
-
|
|
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;
|
|
43705
43771
|
`;
|
|
43706
43772
|
|
|
43707
43773
|
// src/writers/single-mode.ts
|
|
@@ -43757,7 +43823,9 @@ var generateTarget = (builder, options) => {
|
|
|
43757
43823
|
provideIn: options.override.angular.provideIn,
|
|
43758
43824
|
hasAwaitedType,
|
|
43759
43825
|
titles,
|
|
43760
|
-
output: options
|
|
43826
|
+
output: options,
|
|
43827
|
+
verbOptions: builder.verbOptions,
|
|
43828
|
+
clientImplementation: acc.implementation
|
|
43761
43829
|
});
|
|
43762
43830
|
acc.implementation = header.implementation + acc.implementation;
|
|
43763
43831
|
acc.implementationMock.handler = acc.implementationMock.handler + header.implementationMock + acc.implementationMock.handlerName;
|
|
@@ -43933,7 +44001,7 @@ var writeSplitMode = async ({
|
|
|
43933
44001
|
});
|
|
43934
44002
|
mockData += builder.importsMock({
|
|
43935
44003
|
implementation: implementationMock,
|
|
43936
|
-
imports: [{ exports:
|
|
44004
|
+
imports: [{ exports: importsMock, dependency: relativeSchemasPath }],
|
|
43937
44005
|
specsName,
|
|
43938
44006
|
hasSchemaDir: !!output.schemas,
|
|
43939
44007
|
isAllowSyntheticDefaultImports,
|
|
@@ -44089,7 +44157,10 @@ var generateTargetForTags = (builder, options) => {
|
|
|
44089
44157
|
provideIn: options.override.angular.provideIn,
|
|
44090
44158
|
hasAwaitedType,
|
|
44091
44159
|
titles,
|
|
44092
|
-
output: options
|
|
44160
|
+
output: options,
|
|
44161
|
+
verbOptions: builder.verbOptions,
|
|
44162
|
+
tag,
|
|
44163
|
+
clientImplementation: target.implementation
|
|
44093
44164
|
});
|
|
44094
44165
|
acc2[tag] = {
|
|
44095
44166
|
implementation: header.implementation + target.implementation + footer.implementation,
|
|
@@ -44176,7 +44247,7 @@ var writeSplitTagsMode = async ({
|
|
|
44176
44247
|
});
|
|
44177
44248
|
mockData += builder.importsMock({
|
|
44178
44249
|
implementation: implementationMock,
|
|
44179
|
-
imports:
|
|
44250
|
+
imports: [{ exports: importsMock, dependency: relativeSchemasPath }],
|
|
44180
44251
|
specsName,
|
|
44181
44252
|
hasSchemaDir: !!output.schemas,
|
|
44182
44253
|
isAllowSyntheticDefaultImports,
|
|
@@ -44309,7 +44380,9 @@ var writeTagsMode = async ({
|
|
|
44309
44380
|
if (output.mock) {
|
|
44310
44381
|
data += builder.importsMock({
|
|
44311
44382
|
implementation: implementationMock,
|
|
44312
|
-
imports:
|
|
44383
|
+
imports: [
|
|
44384
|
+
{ exports: importsMock, dependency: schemasPathRelative }
|
|
44385
|
+
],
|
|
44313
44386
|
specsName,
|
|
44314
44387
|
hasSchemaDir: !!output.schemas,
|
|
44315
44388
|
isAllowSyntheticDefaultImports,
|