@orval/core 7.1.1 → 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.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,