@orval/core 7.6.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 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;
@@ -437,6 +445,7 @@ type NormalizedQueryOptions = {
437
445
  shouldExportMutatorHooks?: boolean;
438
446
  shouldExportHttpClient?: boolean;
439
447
  shouldExportQueryKey?: boolean;
448
+ shouldSplitQueryKey?: boolean;
440
449
  signal?: boolean;
441
450
  version?: 3 | 4 | 5;
442
451
  };
@@ -455,6 +464,7 @@ type QueryOptions = {
455
464
  shouldExportMutatorHooks?: boolean;
456
465
  shouldExportHttpClient?: boolean;
457
466
  shouldExportQueryKey?: boolean;
467
+ shouldSplitQueryKey?: boolean;
458
468
  signal?: boolean;
459
469
  version?: 3 | 4 | 5;
460
470
  };
@@ -1087,6 +1097,7 @@ declare const combineSchemas: ({ name, schema, separator, context, nullable, }:
1087
1097
 
1088
1098
  declare const resolveDiscriminators: (schemas: SchemasObject, context: ContextSpecs) => SchemasObject;
1089
1099
 
1100
+ declare const getEnumNames: (schemaObject: SchemaObject$1 | undefined) => any;
1090
1101
  declare const getEnum: (value: string, enumName: string, names?: string[], useNativeEnums?: boolean) => string;
1091
1102
  declare const getEnumImplementation: (value: string, names?: string[]) => string;
1092
1103
 
@@ -1471,4 +1482,4 @@ declare const generateTarget: (builder: WriteSpecsBuilder, options: NormalizedOu
1471
1482
 
1472
1483
  declare const generateTargetForTags: (builder: WriteSpecsBuilder, options: NormalizedOutputOptions) => Record<string, GeneratorTarget>;
1473
1484
 
1474
- 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?.["x-enumNames"],
49753
+ getEnumNames(resolvedValue.originalSchema),
49750
49754
  context.output.override.useNativeEnums
49751
49755
  );
49752
49756
  return {
49753
- value: context.output.override.useNativeEnums ? `(keyof typeof ${propName})` : propName,
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.isEnum && context.output.override.useNativeEnums ? `(keyof typeof ${resolvedValue.value})` : resolvedValue.value};`;
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
- const joined = `${resolvedData.values.join(` & `)}${resolvedValue ? ` & ${resolvedValue.value}` : ""}`;
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]?.["x-enumNames"];
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?.["x-enumNames"],
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
- if (mutator.hasErrorType && implementation.includes(mutator.errorTypeName) && !acc.includes(mutator.errorTypeName)) {
51367
- errorImportName = mutator.default ? `ErrorType as ${mutator.errorTypeName}` : mutator.errorTypeName;
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
- if (mutator.bodyTypeName && implementation.includes(mutator.bodyTypeName) && !acc.includes(mutator.bodyTypeName)) {
51371
- bodyImportName = mutator.default ? `BodyType as ${mutator.bodyTypeName}` : mutator.bodyTypeName;
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
  }
@@ -52036,7 +52051,7 @@ var generateInterface = ({
52036
52051
  }
52037
52052
  }
52038
52053
  if (scalar.type === "object" && !context?.output.override?.useTypeOverInterfaces) {
52039
- if (scalar.type === "object" && schema.properties && Object.values(schema.properties).every((item) => "const" in item)) {
52054
+ if (scalar.type === "object" && schema.properties && Object.values(schema.properties).length > 0 && Object.values(schema.properties).every((item) => "const" in item)) {
52040
52055
  const mappedScalarValue = scalar.value.replaceAll(";", ",");
52041
52056
  model += `export const ${name}Value = ${mappedScalarValue} as const;
52042
52057
  export type ${name} = typeof ${name}Value;
@@ -52111,7 +52126,7 @@ var generateSchemasDefinition = (schemas = {}, context, suffix, filters) => {
52111
52126
  output += getEnum(
52112
52127
  resolvedValue.value,
52113
52128
  schemaName,
52114
- resolvedValue.originalSchema?.["x-enumNames"],
52129
+ getEnumNames(resolvedValue.originalSchema),
52115
52130
  context.output.override.useNativeEnums
52116
52131
  );
52117
52132
  } else if (schemaName === resolvedValue.value && resolvedValue.isRef) {
@@ -52433,7 +52448,7 @@ var writeSchemas = async ({
52433
52448
  } else {
52434
52449
  duplicateNamesMap.set(
52435
52450
  schema.name,
52436
- (duplicateNamesMap.get(schema.name) || 0) + 1
52451
+ (duplicateNamesMap.get(schema.name) || 1) + 1
52437
52452
  );
52438
52453
  }
52439
52454
  });
@@ -52603,7 +52618,10 @@ var writeSingleMode = async ({
52603
52618
  }) => {
52604
52619
  try {
52605
52620
  const { path: path2, dirname: dirname3 } = getFileInfo(output.target, {
52606
- backupFilename: camel(builder.info.title),
52621
+ backupFilename: conventionName(
52622
+ builder.info.title,
52623
+ output.namingConvention
52624
+ ),
52607
52625
  extension: output.fileExtension
52608
52626
  });
52609
52627
  const {
@@ -52704,7 +52722,10 @@ var writeSplitMode = async ({
52704
52722
  }) => {
52705
52723
  try {
52706
52724
  const { filename, dirname: dirname3, extension } = getFileInfo(output.target, {
52707
- backupFilename: camel(builder.info.title),
52725
+ backupFilename: conventionName(
52726
+ builder.info.title,
52727
+ output.namingConvention
52728
+ ),
52708
52729
  extension: output.fileExtension
52709
52730
  });
52710
52731
  const {
@@ -53280,6 +53301,7 @@ var writeTagsMode = async ({
53280
53301
  getBody,
53281
53302
  getEnum,
53282
53303
  getEnumImplementation,
53304
+ getEnumNames,
53283
53305
  getExtension,
53284
53306
  getFileInfo,
53285
53307
  getFullRoute,