-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Summary
The form should save only schema dedined mandatory fields, schema defined defaults or user-entered data only.
General Functionality
The current implementation uses the JSON Schema + JSON data to dynamically generate the editor UI. There are two cases:
- Creating a new document: In this case the data is auto-generated with default empty values.
- Authoring an existing document: In this case the editor will get already saved data loaded.
A field can have a value from one of:
- Default from schema — Value from the schema
defaultkeyword - User-entered — Value typed or selected by the user
- Auto-generated — Value produced by the data generator (e.g. empty string, empty array) for UI rendering
Problem
Currently the form stores the complete JSON data—not only the user-entered data but the auto-generated default values as well.
The generated values are used to ensure the UI can render the corresponding input with some default values. However, all these generated values are not needed to be saved all the time.
Expected Behavior
JSON Schema supports the option to mark a field as required. This feature adds the restriction that the property marked required must be present in the JSON data, but does not enforce anything about its value.
The editor should store the JSON data having (in priority order):
- P1 — All data properties that are marked as required
- P2 — Default values defined by the schema
- P3 — If validation is defined in the schema (e.g.
format, etc.) → only valid values are stored - P4 — User-entered data — but not auto-generated default values
Additional benefit: JSON to HTML Output
In this way, saving the JSON as HTML would also remove a lot of empty unnecessary blocks.