Skip to content

OEDP: JavaScript Library to generate Data Passport from the Data Passport's JSON Schema #32

@nikiluk

Description

@nikiluk

JSON Schema is a specification for defining the structure of JSON data. We use JSON Schema because it is a useful tool for describing the required content for the Data Passport (and other elements of the OETP, Transparency Protocol will be using the JSON Schema too).

JSON Schema could also be used for generating web forms where the users will input the exact data for their Data Passport, Open Ethics Label etc, because the schema allows us to define the structure and constraints (which fields are required, what are the format limitations etc) of a form in a language-agnostic way.

Here are some reasons why we should use JSON Schema instead of manual way of managing fields and how it can be useful for generating forms:

Why use JSON Schema?

  1. Language-agnostic: JSON Schema is language-agnostic, which means you can use it to define the structure of your data regardless of the programming language you're using.
  2. Data validation: JSON Schema allows you to define the constraints of your data, such as required fields, data types, and format, which ensures that the data is valid and consistent.
  3. Reusable: JSON Schema can be reused across different applications and platforms, making it a great tool for defining a standard structure for your data.
  4. Machine-readable: JSON Schema is machine-readable, which means you can use it to generate forms, validate data, and perform other automated tasks.

Why is JSON Schema useful for generating forms?

  1. Automatic form generation: JSON Schema can be used to generate forms automatically, which saves time and reduces the risk of errors.
  2. Form validation: JSON Schema can be used to validate form data, ensuring that the user-input data conforms to the defined structure and constraints.
  3. Dynamic forms: JSON Schema can be used to generate dynamic forms that adapt to the user's input, such as conditional fields or dependent dropdowns.
  4. Reusability: JSON Schema can be reused across different forms, applications, and platforms, making it a great tool for defining a standard structure for your forms.

The task

The task is to identify, adapt if necessary, test, and deploy the library out of the existing libraries for the form generation from JSON Schema.

Deliverable

As a result, the HTML/CSS/JavaScript code should be created that will take the JSON Schema URL from the Open Ethics website () and generate a form from it on the fly. It's preferable to use the plain JavaScript and not use libraries/frameworks like React or Angular.

The impact

The idea is that the changes to the Data Passport or other Schemas could be deployed only in one place but will immediately allow users to fill in the form and generate the Data Passport.json

  • Help other people with the same need to work with schema (the code will be opensourced)
  • Streamline working with forms, allowing also to generate OEDP, or OEL from the most recent updates in the Schema (for example right now we are not using the schema for the Open Ethics Label but we could https://openethics.ai/label/generate/)

Some references

https://rjsf-team.github.io/react-jsonschema-form/
https://jsonforms.io/
https://stackoverflow.com/questions/20241059/how-to-create-a-form-from-a-json-schema

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions