OpenEthicsAI / OEDP

Open Ethics Data Passport
https://openethics.ai/oedp/
MIT License
2 stars 4 forks source link

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

Open nikiluk opened 3 hours ago

nikiluk commented 3 hours ago

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

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

nikiluk commented 3 hours ago

The general workflow:

  1. Open Ethics Contributors work on the required components of the JSON Schema, it gets committed and merged to the main branch of OEDP repo (this is set up and the draft schema is in place)

  2. Then Schema gets deployed automatically to Open Ethics website from the GitHub actions (already developed)
  3. The forms are updated automatically without any need for human intervention or development, thanks to the script deployed via this task
  4. The product owners always are exposed to the updated Data Passport forms and can generate valid Data Passport.json files as a result (future outcome)