@orval/core 7.1.0 → 7.2.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
@@ -664,7 +664,7 @@ type ClientFooterBuilder = (params: {
664
664
  hasMutator: boolean;
665
665
  }) => string;
666
666
  type ClientTitleBuilder = (title: string) => string;
667
- type ClientDependenciesBuilder = (hasGlobalMutator: boolean, hasParamsSerializerOptions: boolean, packageJson?: PackageJson, httpClient?: OutputHttpClient) => GeneratorDependency[];
667
+ type ClientDependenciesBuilder = (hasGlobalMutator: boolean, hasParamsSerializerOptions: boolean, packageJson?: PackageJson, httpClient?: OutputHttpClient, hasTagsMutator?: boolean) => GeneratorDependency[];
668
668
  type ClientMockGeneratorImplementation = {
669
669
  function: string;
670
670
  handlerName: string;
@@ -865,6 +865,7 @@ type GeneratorClientImports = (data: {
865
865
  hasSchemaDir: boolean;
866
866
  isAllowSyntheticDefaultImports: boolean;
867
867
  hasGlobalMutator: boolean;
868
+ hasTagsMutator: boolean;
868
869
  hasParamsSerializerOptions: boolean;
869
870
  packageJson?: PackageJson;
870
871
  output: NormalizedOutputOptions;
package/dist/index.js CHANGED
@@ -47253,21 +47253,39 @@ var resolveSchemaPropertiesToFormData = ({
47253
47253
  );
47254
47254
  if (itemSchema.type === "object" || itemSchema.type === "array") {
47255
47255
  valueStr = "JSON.stringify(value)";
47256
- } else if (itemSchema.type === "number" || itemSchema.type === "integer" || itemSchema.type === "boolean") {
47256
+ } else if (itemSchema.type === "number" || itemSchema.type?.includes("number") || itemSchema.type === "integer" || itemSchema.type?.includes("integer") || itemSchema.type === "boolean" || itemSchema.type?.includes("boolean")) {
47257
47257
  valueStr = "value.toString()";
47258
47258
  }
47259
47259
  }
47260
47260
  formDataValue = `${valueKey}.forEach(value => ${variableName}.append('${key}', ${valueStr}));
47261
47261
  `;
47262
- } else if (property.type === "number" || property.type === "integer" || property.type === "boolean") {
47262
+ } else if (property.type === "number" || property.type?.includes("number") || property.type === "integer" || property.type?.includes("integer") || property.type === "boolean" || property.type?.includes("boolean")) {
47263
47263
  formDataValue = `${variableName}.append('${key}', ${nonOptionalValueKey}.toString())
47264
47264
  `;
47265
47265
  } else {
47266
47266
  formDataValue = `${variableName}.append('${key}', ${nonOptionalValueKey})
47267
47267
  `;
47268
47268
  }
47269
+ let existSubSchemaNullable = false;
47270
+ if (property.allOf || property.anyOf || property.oneOf) {
47271
+ const combine = property.allOf || property.anyOf || property.oneOf;
47272
+ const subSchemas = combine?.map(
47273
+ (c2) => resolveObject({ schema: c2, combined: true, context })
47274
+ );
47275
+ if (subSchemas?.some((subSchema) => {
47276
+ return ["number", "integer", "boolean"].includes(subSchema.type);
47277
+ })) {
47278
+ formDataValue = `${variableName}.append('${key}', ${nonOptionalValueKey}.toString())
47279
+ `;
47280
+ }
47281
+ if (subSchemas?.some((subSchema) => {
47282
+ return subSchema.type === "null";
47283
+ })) {
47284
+ existSubSchemaNullable = true;
47285
+ }
47286
+ }
47269
47287
  const isRequired = schema.required?.includes(key) && !isRequestBodyOptional;
47270
- if (property.nullable) {
47288
+ if (property.nullable || property.type?.includes("null") || existSubSchemaNullable) {
47271
47289
  if (isRequired) {
47272
47290
  return acc + `if(${valueKey} !== null) {
47273
47291
  ${formDataValue} }
@@ -47556,7 +47574,7 @@ var getScalar = ({
47556
47574
  isEnum = true;
47557
47575
  }
47558
47576
  const itemWithConst2 = item;
47559
- if (itemWithConst2.const) {
47577
+ if (itemWithConst2.const !== void 0) {
47560
47578
  value2 = itemWithConst2.const;
47561
47579
  }
47562
47580
  return {
@@ -47574,7 +47592,7 @@ var getScalar = ({
47574
47592
  case "boolean":
47575
47593
  let value = "boolean";
47576
47594
  const itemWithConst = item;
47577
- if (itemWithConst.const) {
47595
+ if (itemWithConst.const !== void 0) {
47578
47596
  value = itemWithConst.const;
47579
47597
  }
47580
47598
  return {
@@ -47725,6 +47743,16 @@ var combineSchemas = ({
47725
47743
  if (propName && acc.schemas.length) {
47726
47744
  propName = propName + pascal(getNumberWord(acc.schemas.length + 1));
47727
47745
  }
47746
+ if (separator2 === "allOf" && schema.required) {
47747
+ if (isSchema(subSchema) && subSchema.required) {
47748
+ subSchema = {
47749
+ ...subSchema,
47750
+ required: [...schema.required, ...subSchema.required]
47751
+ };
47752
+ } else {
47753
+ subSchema = { ...subSchema, required: schema.required };
47754
+ }
47755
+ }
47728
47756
  const resolvedValue2 = resolveObject({
47729
47757
  schema: subSchema,
47730
47758
  propName,
@@ -49593,6 +49621,9 @@ var writeSingleMode = async ({
49593
49621
  hasSchemaDir: !!output.schemas,
49594
49622
  isAllowSyntheticDefaultImports,
49595
49623
  hasGlobalMutator: !!output.override.mutator,
49624
+ hasTagsMutator: Object.values(output.override.tags).some(
49625
+ (tag) => !!tag.mutator
49626
+ ),
49596
49627
  hasParamsSerializerOptions: !!output.override.paramsSerializerOptions,
49597
49628
  packageJson: output.packageJson,
49598
49629
  output
@@ -49685,6 +49716,9 @@ var writeSplitMode = async ({
49685
49716
  hasSchemaDir: !!output.schemas,
49686
49717
  isAllowSyntheticDefaultImports,
49687
49718
  hasGlobalMutator: !!output.override.mutator,
49719
+ hasTagsMutator: Object.values(output.override.tags).some(
49720
+ (tag) => !!tag.mutator
49721
+ ),
49688
49722
  hasParamsSerializerOptions: !!output.override.paramsSerializerOptions,
49689
49723
  packageJson: output.packageJson,
49690
49724
  output
@@ -49935,6 +49969,9 @@ var writeSplitTagsMode = async ({
49935
49969
  hasSchemaDir: !!output.schemas,
49936
49970
  isAllowSyntheticDefaultImports,
49937
49971
  hasGlobalMutator: !!output.override.mutator,
49972
+ hasTagsMutator: Object.values(output.override.tags).some(
49973
+ (tag2) => !!tag2.mutator
49974
+ ),
49938
49975
  hasParamsSerializerOptions: !!output.override.paramsSerializerOptions,
49939
49976
  packageJson: output.packageJson,
49940
49977
  output
@@ -50071,6 +50108,9 @@ var writeTagsMode = async ({
50071
50108
  hasSchemaDir: !!output.schemas,
50072
50109
  isAllowSyntheticDefaultImports,
50073
50110
  hasGlobalMutator: !!output.override.mutator,
50111
+ hasTagsMutator: Object.values(output.override.tags).some(
50112
+ (tag2) => !!tag2.mutator
50113
+ ),
50074
50114
  hasParamsSerializerOptions: !!output.override.paramsSerializerOptions,
50075
50115
  packageJson: output.packageJson,
50076
50116
  output