Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON Schema definition of the submitted data to the JSON registration backend plugin #4980

Open
Tracked by #4908
viktorvanwijk opened this issue Jan 2, 2025 · 0 comments · May be fixed by #5007
Open
Tracked by #4908
Assignees
Labels
enhancement owner: venlo topic: registration waiting for approval An estimate was made but the stakeholder still needs to approve it.
Milestone

Comments

@viktorvanwijk
Copy link
Contributor

viktorvanwijk commented Jan 2, 2025

Sub task of #4908

Example

An example form with the following configuration:

  • Authentication via DigiD, capturing a BSN
  • First form step with text fields firstName and lastName
  • Second form step with a user upload attachment

Should lead to a JSON object being sent with the shape:

{
    "values":
    {
        "auth_bsn": "123456782",
        "firstName": "Donnie",
        "lastName": "Darko",
        "attachment": "<base64 encoded data>"
    },
    "schema":
    {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties":
        {
            "auth_bsn":
            {
                "type": "string",
                "pattern": "^\\d{9}$"
            },
            "firstName":
            {
                "type": "string"
            },
            "lastName":
            {
                "type": "string"
            },
            "attachment":
            {
                "type": "string",
                "contentEncoding": "base64"
            }
        },
        "required":
        [
            "auth_bsn",
            "firstName",
            "lastName"
        ],
        "additionalProperties": false
    }
}
@viktorvanwijk viktorvanwijk self-assigned this Jan 2, 2025
@viktorvanwijk viktorvanwijk added enhancement topic: registration waiting for approval An estimate was made but the stakeholder still needs to approve it. owner: venlo labels Jan 2, 2025
@viktorvanwijk viktorvanwijk changed the title Optionally, a JSON Schema definition of the submitted data is provided in the schema key Add JSON Schema definition of the submitted data to the JSON registration backend Jan 2, 2025
@viktorvanwijk viktorvanwijk changed the title Add JSON Schema definition of the submitted data to the JSON registration backend Add JSON Schema definition of the submitted data to the JSON registration backend plugin Jan 2, 2025
viktorvanwijk added a commit that referenced this issue Jan 2, 2025
…lugin

Just as an example of what will be implemented in #4980
@viktorvanwijk viktorvanwijk added this to the Release 3.1.0 milestone Jan 6, 2025
@viktorvanwijk viktorvanwijk moved this from Todo to In Progress in Development Jan 6, 2025
viktorvanwijk added a commit that referenced this issue Jan 8, 2025
The schema for the registration variables are left out for now, as they can't be selected in the JSON dump plugin options
viktorvanwijk added a commit that referenced this issue Jan 8, 2025
…f variables to include

Also updated the JSON dump plugin
viktorvanwijk added a commit that referenced this issue Jan 8, 2025
- Add test for JSON schemas of formio components
- Add test for form to JSON schema
viktorvanwijk added a commit that referenced this issue Jan 9, 2025
The schema for the registration variables are left out for now, as they can't be selected in the JSON dump plugin options
viktorvanwijk added a commit that referenced this issue Jan 9, 2025
…f variables to include

Also updated the JSON dump plugin
viktorvanwijk added a commit that referenced this issue Jan 9, 2025
- Add test for JSON schemas of formio components
- Add test for form to JSON schema
viktorvanwijk added a commit that referenced this issue Jan 9, 2025
…f variables to include

Also updated the JSON dump plugin
viktorvanwijk added a commit that referenced this issue Jan 9, 2025
- Add test for JSON schemas of formio components
- Add test for form to JSON schema
viktorvanwijk added a commit that referenced this issue Jan 9, 2025
There was a bug with the previous attachment processing, where attachments would get overwritten if multiple were uploaded
viktorvanwijk added a commit that referenced this issue Jan 10, 2025
The schema for the registration variables are left out for now, as they can't be selected in the JSON dump plugin options
viktorvanwijk added a commit that referenced this issue Jan 10, 2025
…f variables to include

Also updated the JSON dump plugin
viktorvanwijk added a commit that referenced this issue Jan 10, 2025
- Add test for JSON schemas of formio components
- Add test for form to JSON schema
viktorvanwijk added a commit that referenced this issue Jan 10, 2025
Also add support for user-defined variables
viktorvanwijk added a commit that referenced this issue Jan 10, 2025
viktorvanwijk added a commit that referenced this issue Jan 13, 2025
…a source

When a select component has a form variable as data source, the 'enum' property in the JSON schema is currently unfilled, because the 'values' option of the component is an empty list.

Solution is to fetch the corresponding form variable and update the 'enum' property in the schema accordingly
viktorvanwijk added a commit that referenced this issue Jan 13, 2025
… a data source

When a select box component has a form variable as data source, the 'properties' and 'required' properties in the JSON schema are currently unfilled, because the 'values' option of the component is an empty list.

Solution is to fetch the corresponding form variable and update the 'properties' and 'required' property in the schema accordingly
viktorvanwijk added a commit that referenced this issue Jan 13, 2025
Clarifies which properties can be expected
viktorvanwijk added a commit that referenced this issue Jan 13, 2025
…led field

If a field is not required, but sent anyway, it's value is an empty string
viktorvanwijk added a commit that referenced this issue Jan 13, 2025
…t if no value was submitted

If the component is not required, the value is an empty dict, which means there are no required properties
viktorvanwijk added a commit that referenced this issue Jan 13, 2025
…JSON schema when the data source is not another form variable

If the data source is a form variable, the list of options is not available here, so it doesn't make sense to include the enum/properties in the JSON schema
viktorvanwijk added a commit that referenced this issue Jan 14, 2025
There was a bug with the previous attachment processing, where attachments would get overwritten if multiple were uploaded. Now, they are added to a dictionary with their original name as a key
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
…lugin

Just as an example of what will be implemented in #4980
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
There was a bug with the previous attachment processing, where attachments would get overwritten if multiple were uploaded
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
The schema for the registration variables are left out for now, as they can't be selected in the JSON dump plugin options
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
…f variables to include

Also updated the JSON dump plugin
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
- Add test for JSON schemas of formio components
- Add test for form to JSON schema
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
Also add support for user-defined variables
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
…a source

When a select component has a form variable as data source, the 'enum' property in the JSON schema is currently unfilled, because the 'values' option of the component is an empty list.

Solution is to fetch the corresponding form variable and update the 'enum' property in the schema accordingly
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
… a data source

When a select box component has a form variable as data source, the 'properties' and 'required' properties in the JSON schema are currently unfilled, because the 'values' option of the component is an empty list.

Solution is to fetch the corresponding form variable and update the 'properties' and 'required' property in the schema accordingly
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
Clarifies which properties can be expected
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
…led field

If a field is not required, but sent anyway, it's value is an empty string
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
…t if no value was submitted

If the component is not required, the value is an empty dict, which means there are no required properties
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
…JSON schema when the data source is not another form variable

If the data source is a form variable, the list of options is not available here, so it doesn't make sense to include the enum/properties in the JSON schema
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
…when the data source is another form variable

This data is not available in the component.as_json_schema methods based on the form alone, because all user defined variables and calculated values are saved in the DB at the moment of submission. So just the form is not enough to get this data, and we need to do some post-processing in the plugin where we have the submission available
viktorvanwijk added a commit that referenced this issue Jan 15, 2025
These things are tested in test_component_json_schemas.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement owner: venlo topic: registration waiting for approval An estimate was made but the stakeholder still needs to approve it.
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

1 participant