Skip to content

[dasc] Persist Only Required Fields, Schema Defaults, and User Data #196

@kozmaadrian

Description

@kozmaadrian

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 default keyword
  • 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):

  1. P1 — All data properties that are marked as required
  2. P2 — Default values defined by the schema
  3. P3 — If validation is defined in the schema (e.g. format, etc.) → only valid values are stored
  4. 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.

Metadata

Metadata

Assignees

Labels

dascUsed by DA Structured Content

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions