Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/core/test/Form.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1354,23 +1354,23 @@ describeRepeated('Form common', (createFormComponent) => {
name: 'required',
params: { missingProperty: 'street_address' },
property: '.shipping_address.street_address',
schemaPath: '#/definitions/address/required',
schemaPath: '#/properties/shipping_address/required',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the updated code, it will now resolve the property ref that was used multiple times.

stack: "must have required property 'street_address'",
},
{
message: "must have required property 'city'",
name: 'required',
params: { missingProperty: 'city' },
property: '.shipping_address.city',
schemaPath: '#/definitions/address/required',
schemaPath: '#/properties/shipping_address/required',
stack: "must have required property 'city'",
},
{
message: "must have required property 'state'",
name: 'required',
params: { missingProperty: 'state' },
property: '.shipping_address.state',
schemaPath: '#/definitions/address/required',
schemaPath: '#/properties/shipping_address/required',
stack: "must have required property 'state'",
},
]);
Expand Down
9 changes: 8 additions & 1 deletion packages/utils/src/schema/retrieveSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import isEqual from 'lodash/isEqual';
import set from 'lodash/set';
import times from 'lodash/times';
import transform from 'lodash/transform';
import merge from 'lodash/merge';
import flattenDeep from 'lodash/flattenDeep';
import uniq from 'lodash/uniq';
import mergeAllOf, { Options } from 'json-schema-merge-allof';

import {
Expand Down Expand Up @@ -265,13 +268,17 @@ export function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(
}

if (PROPERTIES_KEY in resolvedSchema) {
const childrenLists: string[][] = [];
const updatedProps = transform(
resolvedSchema[PROPERTIES_KEY]!,
(result, value, key: string) => {
result[key] = resolveAllReferences(value as S, rootSchema, recurseList);
const childList: string[] = [...recurseList];
result[key] = resolveAllReferences(value as S, rootSchema, childList);
childrenLists.push(childList);
},
{} as RJSFSchema
);
merge(recurseList, uniq(flattenDeep(childrenLists)));
resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };
}

Expand Down