@rjsf/utils 5.13.1 → 5.13.3

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
@@ -708,7 +708,7 @@ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expa
708
708
  return resolvedSchema;
709
709
  });
710
710
  }
711
- function resolveAnyOrOneOfSchemas(validator, schema, rootSchema, expandAllBranches, recurseList, rawFormData) {
711
+ function resolveAnyOrOneOfSchemas(validator, schema, rootSchema, expandAllBranches, rawFormData) {
712
712
  let anyOrOneOf;
713
713
  const { oneOf, anyOf, ...remaining } = schema;
714
714
  if (Array.isArray(oneOf)) {
@@ -720,7 +720,7 @@ function resolveAnyOrOneOfSchemas(validator, schema, rootSchema, expandAllBranch
720
720
  const formData = rawFormData === void 0 && expandAllBranches ? {} : rawFormData;
721
721
  const discriminator = getDiscriminatorFieldFromSchema(schema);
722
722
  anyOrOneOf = anyOrOneOf.map((s) => {
723
- return resolveAllReferences(s, rootSchema, recurseList);
723
+ return resolveAllReferences(s, rootSchema, []);
724
724
  });
725
725
  const option = getFirstMatchingOption(validator, formData, anyOrOneOf, rootSchema, discriminator);
726
726
  if (expandAllBranches) {
@@ -737,7 +737,6 @@ function resolveDependencies(validator, schema, rootSchema, expandAllBranches, r
737
737
  remainingSchema,
738
738
  rootSchema,
739
739
  expandAllBranches,
740
- recurseList,
741
740
  formData
742
741
  );
743
742
  return resolvedSchemas.flatMap(
@@ -1578,16 +1577,43 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1578
1577
  (0, import_set2.default)(pathSchema, RJSF_ADDITONAL_PROPERTIES_FLAG, true);
1579
1578
  }
1580
1579
  if (ITEMS_KEY in schema && Array.isArray(formData)) {
1581
- formData.forEach((element, i) => {
1582
- pathSchema[i] = toPathSchemaInternal(
1583
- validator,
1584
- schema.items,
1585
- `${name}.${i}`,
1586
- rootSchema,
1587
- element,
1588
- _recurseList
1589
- );
1590
- });
1580
+ const { items: schemaItems, additionalItems: schemaAdditionalItems } = schema;
1581
+ if (Array.isArray(schemaItems)) {
1582
+ formData.forEach((element, i) => {
1583
+ if (schemaItems[i]) {
1584
+ pathSchema[i] = toPathSchemaInternal(
1585
+ validator,
1586
+ schemaItems[i],
1587
+ `${name}.${i}`,
1588
+ rootSchema,
1589
+ element,
1590
+ _recurseList
1591
+ );
1592
+ } else if (schemaAdditionalItems) {
1593
+ pathSchema[i] = toPathSchemaInternal(
1594
+ validator,
1595
+ schemaAdditionalItems,
1596
+ `${name}.${i}`,
1597
+ rootSchema,
1598
+ element,
1599
+ _recurseList
1600
+ );
1601
+ } else {
1602
+ console.warn(`Unable to generate path schema for "${name}.${i}". No schema defined for it`);
1603
+ }
1604
+ });
1605
+ } else {
1606
+ formData.forEach((element, i) => {
1607
+ pathSchema[i] = toPathSchemaInternal(
1608
+ validator,
1609
+ schemaItems,
1610
+ `${name}.${i}`,
1611
+ rootSchema,
1612
+ element,
1613
+ _recurseList
1614
+ );
1615
+ });
1616
+ }
1591
1617
  } else if (PROPERTIES_KEY in schema) {
1592
1618
  for (const property in schema.properties) {
1593
1619
  const field = (0, import_get10.default)(schema, [PROPERTIES_KEY, property]);
@@ -2637,13 +2663,12 @@ var ParserValidator = class {
2637
2663
 
2638
2664
  // src/parser/schemaParser.ts
2639
2665
  function parseSchema(validator, recurseList, rootSchema, schema) {
2640
- const recurseRefs = [];
2641
- const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true, recurseRefs);
2666
+ const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
2642
2667
  schemas.forEach((schema2) => {
2643
2668
  const sameSchemaIndex = recurseList.findIndex((item) => (0, import_isEqual7.default)(item, schema2));
2644
2669
  if (sameSchemaIndex === -1) {
2645
2670
  recurseList.push(schema2);
2646
- const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true, recurseRefs);
2671
+ const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
2647
2672
  allOptions.forEach((s) => {
2648
2673
  if (PROPERTIES_KEY in s && s[PROPERTIES_KEY]) {
2649
2674
  (0, import_forEach.default)(schema2[PROPERTIES_KEY], (value) => {