Skip to content

Commit ac6b3b0

Browse files
authored
fix: #3961 resolve all recurse list for object properties (#3981)
* fix: resolve all recurse list for object properties * update test * simplfy logic * revert * update change log
1 parent bc16e29 commit ac6b3b0

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ should change the heading of the (upcoming) version to include a major version b
1717
-->
1818
# 5.14.4
1919

20+
## @rjsf/utils
21+
22+
- Updated `resolveAllReferences()` to use own recurse list for each object properties, fixing [#3961](https://github.com/rjsf-team/react-jsonschema-form/issues/3961)
23+
2024
## Dev
25+
2126
- add missing typescript project reference for `utils` in `validator-ajv6` and `validator-ajv8` packages tsconfigs
2227

2328
# 5.14.3

packages/core/test/Form.test.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1354,23 +1354,23 @@ describeRepeated('Form common', (createFormComponent) => {
13541354
name: 'required',
13551355
params: { missingProperty: 'street_address' },
13561356
property: '.shipping_address.street_address',
1357-
schemaPath: '#/definitions/address/required',
1357+
schemaPath: '#/properties/shipping_address/required',
13581358
stack: "must have required property 'street_address'",
13591359
},
13601360
{
13611361
message: "must have required property 'city'",
13621362
name: 'required',
13631363
params: { missingProperty: 'city' },
13641364
property: '.shipping_address.city',
1365-
schemaPath: '#/definitions/address/required',
1365+
schemaPath: '#/properties/shipping_address/required',
13661366
stack: "must have required property 'city'",
13671367
},
13681368
{
13691369
message: "must have required property 'state'",
13701370
name: 'required',
13711371
params: { missingProperty: 'state' },
13721372
property: '.shipping_address.state',
1373-
schemaPath: '#/definitions/address/required',
1373+
schemaPath: '#/properties/shipping_address/required',
13741374
stack: "must have required property 'state'",
13751375
},
13761376
]);

packages/utils/src/schema/retrieveSchema.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import isEqual from 'lodash/isEqual';
33
import set from 'lodash/set';
44
import times from 'lodash/times';
55
import transform from 'lodash/transform';
6+
import merge from 'lodash/merge';
7+
import flattenDeep from 'lodash/flattenDeep';
8+
import uniq from 'lodash/uniq';
69
import mergeAllOf, { Options } from 'json-schema-merge-allof';
710

811
import {
@@ -265,13 +268,17 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
265268
}
266269

267270
if (PROPERTIES_KEY in resolvedSchema) {
271+
const childrenLists: string[][] = [];
268272
const updatedProps = transform(
269273
resolvedSchema[PROPERTIES_KEY]!,
270274
(result, value, key: string) => {
271-
result[key] = resolveAllReferences(value as S, rootSchema, recurseList);
275+
const childList: string[] = [...recurseList];
276+
result[key] = resolveAllReferences(value as S, rootSchema, childList);
277+
childrenLists.push(childList);
272278
},
273279
{} as RJSFSchema
274280
);
281+
merge(recurseList, uniq(flattenDeep(childrenLists)));
275282
resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };
276283
}
277284

0 commit comments

Comments
 (0)