Skip to content

Commit 1f989fe

Browse files
LausselloicLAUSSEL Loic INNOV/IT-Sheath-freenome
committed
backport PR rjsf-team#2631 to take into account additionalProperties set to false (rjsf-team#2940)
* backport PR rjsf-team#2631 to take into account additionalProperties set to false in schema # Conflicts: # packages/utils/src/schema/toPathSchema.ts # packages/utils/test/schema/toPathSchemaTest.ts * move to fix from rjsf-team#2853 * fix linting error * run cs-format on modified files * Update packages/utils/src/schema/toPathSchema.ts Fix formatting (hopefully) * Update packages/utils/src/schema/toPathSchema.ts Second try fixing formatting Co-authored-by: LAUSSEL Loic INNOV/IT-S <[email protected]> Co-authored-by: Heath C <[email protected]>
1 parent 97e0f14 commit 1f989fe

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ should change the heading of the (upcoming) version to include a major version b
1616
1717
-->
1818
# v5.0.0 (coming soon)
19+
## @rjsf/utils
20+
- clear errors on formData change when liveOmit=true when "additionalProperties: false" [issue 1507](https://github.com/rjsf-team/react-jsonschema-form/issues/1507) (https://github.com/rjsf-team/react-jsonschema-form/pull/2631)
1921

2022
## @rjsf/core
2123
- Fix overriding core submit button className (https://github.com/rjsf-team/react-jsonschema-form/issues/2979)

packages/utils/src/schema/toPathSchema.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ export default function toPathSchema<T = any>(
3939
[NAME_KEY]: name.replace(/^\./, ""),
4040
} as PathSchema;
4141

42-
if (ADDITIONAL_PROPERTIES_KEY in schema) {
42+
if (
43+
ADDITIONAL_PROPERTIES_KEY in schema &&
44+
schema[ADDITIONAL_PROPERTIES_KEY] === true
45+
) {
4346
set(pathSchema, RJSF_ADDITONAL_PROPERTIES_FLAG, true);
4447
}
4548

packages/utils/test/schema/toPathSchemaTest.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ export default function toPathSchemaTest(testValidator: TestValidatorType) {
1616
__rjsf_additionalProperties: true,
1717
});
1818
});
19+
it("should return a pathSchema for root field, without additional properties", () => {
20+
const schema: RJSFSchema = {
21+
type: "string",
22+
additionalProperties: false,
23+
};
24+
25+
expect(toPathSchema(testValidator, schema)).toEqual({ $name: "" });
26+
});
1927
it("should return a pathSchema for nested objects", () => {
2028
const schema: RJSFSchema = {
2129
type: "object",

0 commit comments

Comments
 (0)