@orval/core 7.7.0 → 7.8.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 +10 -1
- package/dist/index.js +28 -12
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
|
|
|
4
4
|
import { InfoObject, OperationObject, OpenAPIObject, ResponsesObject, ReferenceObject, RequestBodyObject, ParameterObject, SchemaObject, ComponentsObject, SchemasObject, PathItemObject, ResponseObject, ExampleObject } from 'openapi3-ts/oas30';
|
|
5
5
|
import swagger2openapi from 'swagger2openapi';
|
|
6
6
|
import { TypeDocOptions } from 'typedoc';
|
|
7
|
+
import { SchemaObject as SchemaObject$1 } from 'openapi3-ts/dist/model/openapi30';
|
|
7
8
|
import { ValueIteratee } from 'lodash';
|
|
8
9
|
import { ServerObject } from 'openapi3-ts/oas31';
|
|
9
10
|
import { CompareOperator } from 'compare-versions';
|
|
@@ -353,6 +354,11 @@ type NormalizedHonoOptions = {
|
|
|
353
354
|
validator: boolean | 'hono';
|
|
354
355
|
validatorOutputPath: string;
|
|
355
356
|
};
|
|
357
|
+
type ZodDateTimeOptions = {
|
|
358
|
+
offset?: boolean;
|
|
359
|
+
local?: boolean;
|
|
360
|
+
precision?: number;
|
|
361
|
+
};
|
|
356
362
|
type ZodOptions = {
|
|
357
363
|
strict?: {
|
|
358
364
|
param?: boolean;
|
|
@@ -382,6 +388,7 @@ type ZodOptions = {
|
|
|
382
388
|
body?: Mutator;
|
|
383
389
|
response?: Mutator;
|
|
384
390
|
};
|
|
391
|
+
dateTimeOptions?: ZodDateTimeOptions;
|
|
385
392
|
generateEachHttpStatus?: boolean;
|
|
386
393
|
};
|
|
387
394
|
type ZodCoerceType = 'string' | 'number' | 'boolean' | 'bigint' | 'date';
|
|
@@ -415,6 +422,7 @@ type NormalizedZodOptions = {
|
|
|
415
422
|
response?: NormalizedMutator;
|
|
416
423
|
};
|
|
417
424
|
generateEachHttpStatus: boolean;
|
|
425
|
+
dateTimeOptions: ZodDateTimeOptions;
|
|
418
426
|
};
|
|
419
427
|
type HonoOptions = {
|
|
420
428
|
handlers?: string;
|
|
@@ -1089,6 +1097,7 @@ declare const combineSchemas: ({ name, schema, separator, context, nullable, }:
|
|
|
1089
1097
|
|
|
1090
1098
|
declare const resolveDiscriminators: (schemas: SchemasObject, context: ContextSpecs) => SchemasObject;
|
|
1091
1099
|
|
|
1100
|
+
declare const getEnumNames: (schemaObject: SchemaObject$1 | undefined) => any;
|
|
1092
1101
|
declare const getEnum: (value: string, enumName: string, names?: string[], useNativeEnums?: boolean) => string;
|
|
1093
1102
|
declare const getEnumImplementation: (value: string, names?: string[]) => string;
|
|
1094
1103
|
|
|
@@ -1473,4 +1482,4 @@ declare const generateTarget: (builder: WriteSpecsBuilder, options: NormalizedOu
|
|
|
1473
1482
|
|
|
1474
1483
|
declare const generateTargetForTags: (builder: WriteSpecsBuilder, options: NormalizedOutputOptions) => Record<string, GeneratorTarget>;
|
|
1475
1484
|
|
|
1476
|
-
export { type AngularOptions, BODY_TYPE_NAME, type BaseUrlFromConstant, type BaseUrlFromSpec, type ClientBuilder, type ClientDependenciesBuilder, type ClientExtraFilesBuilder, type ClientFileBuilder, type ClientFooterBuilder, type ClientGeneratorsBuilder, type ClientHeaderBuilder, type ClientMockBuilder, type ClientMockGeneratorBuilder, type ClientMockGeneratorImplementation, type ClientTitleBuilder, type Config, type ConfigExternal, type ConfigFn, type ContextSpecs, type FetchOptions, 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 InputFiltersOption, 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, NamingConvention, 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, type OutputDocsOptions, OutputHttpClient, OutputMockType, OutputMode, type OutputOptions, type OverrideInput, type OverrideMockOptions, type OverrideOutput, type OverrideOutputContentType, type PackageJson, type ParamsSerializerOptions, PropertySortOrder, type QueryOptions, RefComponentSuffix, type RefInfo, type ResReqTypesValue, type ResolverValue, type ScalarValue, SchemaType, type SchemaWithConst, type SwaggerParserOptions, type SwrOptions, TEMPLATE_TAG_REGEX, type TsConfigTarget, type Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, type WriteModeProps, type WriteSpecsBuilder, type ZodCoerceType, type ZodOptions, _filteredVerbs, addDependency, asyncReduce, camel, combineSchemas, compareVersions, conventionName, 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, getFullRoute, getIsBodyVerb, 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 };
|
|
1485
|
+
export { type AngularOptions, BODY_TYPE_NAME, type BaseUrlFromConstant, type BaseUrlFromSpec, type ClientBuilder, type ClientDependenciesBuilder, type ClientExtraFilesBuilder, type ClientFileBuilder, type ClientFooterBuilder, type ClientGeneratorsBuilder, type ClientHeaderBuilder, type ClientMockBuilder, type ClientMockGeneratorBuilder, type ClientMockGeneratorImplementation, type ClientTitleBuilder, type Config, type ConfigExternal, type ConfigFn, type ContextSpecs, type FetchOptions, 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 InputFiltersOption, 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, NamingConvention, 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, type OutputDocsOptions, OutputHttpClient, OutputMockType, OutputMode, type OutputOptions, type OverrideInput, type OverrideMockOptions, type OverrideOutput, type OverrideOutputContentType, type PackageJson, type ParamsSerializerOptions, PropertySortOrder, type QueryOptions, RefComponentSuffix, type RefInfo, type ResReqTypesValue, type ResolverValue, type ScalarValue, SchemaType, type SchemaWithConst, type SwaggerParserOptions, type SwrOptions, TEMPLATE_TAG_REGEX, type TsConfigTarget, type Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, type WriteModeProps, type WriteSpecsBuilder, type ZodCoerceType, type ZodDateTimeOptions, type ZodOptions, _filteredVerbs, addDependency, asyncReduce, camel, combineSchemas, compareVersions, conventionName, 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, getEnumNames, getExtension, getFileInfo, getFullRoute, getIsBodyVerb, 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
|
@@ -48171,6 +48171,7 @@ __export(src_exports, {
|
|
|
48171
48171
|
getBody: () => getBody,
|
|
48172
48172
|
getEnum: () => getEnum,
|
|
48173
48173
|
getEnumImplementation: () => getEnumImplementation,
|
|
48174
|
+
getEnumNames: () => getEnumNames,
|
|
48174
48175
|
getExtension: () => getExtension,
|
|
48175
48176
|
getFileInfo: () => getFileInfo,
|
|
48176
48177
|
getFullRoute: () => getFullRoute,
|
|
@@ -49419,6 +49420,9 @@ var ibmOpenapiValidator = async (specs, validation) => {
|
|
|
49419
49420
|
var getIsBodyVerb = (verb) => VERBS_WITH_BODY.includes(verb);
|
|
49420
49421
|
|
|
49421
49422
|
// src/getters/enum.ts
|
|
49423
|
+
var getEnumNames = (schemaObject) => {
|
|
49424
|
+
return schemaObject?.["x-enumNames"] || schemaObject?.["x-enumnames"] || schemaObject?.["x-enum-varnames"];
|
|
49425
|
+
};
|
|
49422
49426
|
var getEnum = (value, enumName, names, useNativeEnums) => {
|
|
49423
49427
|
const enumValue = useNativeEnums ? getNativeEnum(value, enumName, names) : getTypeConstEnum(value, enumName, names);
|
|
49424
49428
|
return enumValue;
|
|
@@ -49746,11 +49750,11 @@ var resolveObjectOriginal = ({
|
|
|
49746
49750
|
const enumValue = getEnum(
|
|
49747
49751
|
resolvedValue.value,
|
|
49748
49752
|
propName,
|
|
49749
|
-
resolvedValue.originalSchema
|
|
49753
|
+
getEnumNames(resolvedValue.originalSchema),
|
|
49750
49754
|
context.output.override.useNativeEnums
|
|
49751
49755
|
);
|
|
49752
49756
|
return {
|
|
49753
|
-
value:
|
|
49757
|
+
value: propName,
|
|
49754
49758
|
imports: [{ name: propName }],
|
|
49755
49759
|
schemas: [
|
|
49756
49760
|
...resolvedValue.schemas,
|
|
@@ -50369,7 +50373,7 @@ var getObject = ({
|
|
|
50369
50373
|
acc.hasReadonlyProps ||= isReadOnly || false;
|
|
50370
50374
|
acc.imports.push(...resolvedValue.imports);
|
|
50371
50375
|
acc.value += `
|
|
50372
|
-
${doc ? `${doc} ` : ""}${isReadOnly && !context.output.override.suppressReadonlyModifier ? "readonly " : ""}${getKey(key)}${isRequired ? "" : "?"}: ${resolvedValue.
|
|
50376
|
+
${doc ? `${doc} ` : ""}${isReadOnly && !context.output.override.suppressReadonlyModifier ? "readonly " : ""}${getKey(key)}${isRequired ? "" : "?"}: ${resolvedValue.value};`;
|
|
50373
50377
|
acc.schemas.push(...resolvedValue.schemas);
|
|
50374
50378
|
if (arr.length - 1 === index3) {
|
|
50375
50379
|
if (item.additionalProperties) {
|
|
@@ -50622,7 +50626,16 @@ var combineValues = ({
|
|
|
50622
50626
|
return `${resolvedData.values.join(` | `)}${resolvedValue ? ` | ${resolvedValue.value}` : ""}`;
|
|
50623
50627
|
}
|
|
50624
50628
|
if (separator2 === "allOf") {
|
|
50625
|
-
|
|
50629
|
+
let resolvedDataValue = resolvedData.values.join(` & `);
|
|
50630
|
+
if (resolvedData.originalSchema.length > 0 && resolvedValue) {
|
|
50631
|
+
const discriminatedPropertySchemas = resolvedData.originalSchema.filter(
|
|
50632
|
+
(s2) => s2?.discriminator && resolvedValue.value.includes(` ${s2.discriminator.propertyName}:`)
|
|
50633
|
+
);
|
|
50634
|
+
if (discriminatedPropertySchemas.length > 0) {
|
|
50635
|
+
resolvedDataValue = `Omit<${resolvedDataValue}, '${discriminatedPropertySchemas.map((s2) => s2.discriminator?.propertyName).join("' | '")}'>`;
|
|
50636
|
+
}
|
|
50637
|
+
}
|
|
50638
|
+
const joined = `${resolvedDataValue}${resolvedValue ? ` & ${resolvedValue.value}` : ""}`;
|
|
50626
50639
|
const overrideRequiredProperties = resolvedData.requiredProperties.filter(
|
|
50627
50640
|
(prop) => !resolvedData.originalSchema.some(
|
|
50628
50641
|
(schema) => schema && schema.properties?.[prop] && schema.required?.includes(prop)
|
|
@@ -50789,7 +50802,7 @@ var getCombineEnumValue = ({
|
|
|
50789
50802
|
if (isRef[i3]) {
|
|
50790
50803
|
return `...${e3},`;
|
|
50791
50804
|
}
|
|
50792
|
-
const names = originalSchema[i3]
|
|
50805
|
+
const names = getEnumNames(originalSchema[i3]);
|
|
50793
50806
|
return getEnumImplementation(e3, names);
|
|
50794
50807
|
}).join("");
|
|
50795
50808
|
return `{${enums}} as const`;
|
|
@@ -51072,7 +51085,7 @@ var getQueryParamsTypes = (queryParams, operationName, context) => {
|
|
|
51072
51085
|
const enumValue = getEnum(
|
|
51073
51086
|
resolvedValue.value,
|
|
51074
51087
|
enumName,
|
|
51075
|
-
resolvedValue.originalSchema
|
|
51088
|
+
getEnumNames(resolvedValue.originalSchema),
|
|
51076
51089
|
context.output.override.useNativeEnums
|
|
51077
51090
|
);
|
|
51078
51091
|
return {
|
|
@@ -51363,15 +51376,17 @@ var generateMutatorImports = ({
|
|
|
51363
51376
|
acc += "\n";
|
|
51364
51377
|
if (implementation && (mutator.hasErrorType || mutator.bodyTypeName)) {
|
|
51365
51378
|
let errorImportName = "";
|
|
51366
|
-
|
|
51367
|
-
|
|
51379
|
+
const targetErrorImportName = mutator.default ? `ErrorType as ${mutator.errorTypeName}` : mutator.errorTypeName;
|
|
51380
|
+
if (mutator.hasErrorType && implementation.includes(mutator.errorTypeName) && !acc.includes(`{ ${targetErrorImportName} `)) {
|
|
51381
|
+
errorImportName = targetErrorImportName;
|
|
51368
51382
|
}
|
|
51369
51383
|
let bodyImportName = "";
|
|
51370
|
-
|
|
51371
|
-
|
|
51384
|
+
const targetBodyImportName = mutator.default ? `BodyType as ${mutator.bodyTypeName}` : mutator.bodyTypeName;
|
|
51385
|
+
if (mutator.bodyTypeName && implementation.includes(mutator.bodyTypeName) && !acc.includes(` ${targetBodyImportName} }`)) {
|
|
51386
|
+
bodyImportName = targetBodyImportName;
|
|
51372
51387
|
}
|
|
51373
51388
|
if (bodyImportName || errorImportName) {
|
|
51374
|
-
acc += `import type { ${errorImportName}${errorImportName && bodyImportName ? ", " : ""}${bodyImportName} } from '${path2}';`;
|
|
51389
|
+
acc += `import type { ${errorImportName}${errorImportName && bodyImportName ? " , " : ""}${bodyImportName} } from '${path2}';`;
|
|
51375
51390
|
acc += "\n";
|
|
51376
51391
|
}
|
|
51377
51392
|
}
|
|
@@ -52111,7 +52126,7 @@ var generateSchemasDefinition = (schemas = {}, context, suffix, filters) => {
|
|
|
52111
52126
|
output += getEnum(
|
|
52112
52127
|
resolvedValue.value,
|
|
52113
52128
|
schemaName,
|
|
52114
|
-
resolvedValue.originalSchema
|
|
52129
|
+
getEnumNames(resolvedValue.originalSchema),
|
|
52115
52130
|
context.output.override.useNativeEnums
|
|
52116
52131
|
);
|
|
52117
52132
|
} else if (schemaName === resolvedValue.value && resolvedValue.isRef) {
|
|
@@ -53286,6 +53301,7 @@ var writeTagsMode = async ({
|
|
|
53286
53301
|
getBody,
|
|
53287
53302
|
getEnum,
|
|
53288
53303
|
getEnumImplementation,
|
|
53304
|
+
getEnumNames,
|
|
53289
53305
|
getExtension,
|
|
53290
53306
|
getFileInfo,
|
|
53291
53307
|
getFullRoute,
|