Sage-Bionetworks / rocc-schemas

OpenAPI specification of the Registry of Open Community Challenges
Apache License 2.0
0 stars 0 forks source link

Flatten DREAM data JSON files #115

Closed tschaffter closed 3 years ago

tschaffter commented 3 years ago

The idea is for the JSON files to include array of {schema} (e.g. Tag, Organization) or {schema}CreateRequest objects (e.g. Grant, Challenge). This approach will simplify the validation of the JSON data and seeding the database.

For example, the challenge objects listed in challenges.json have their property organizerIds set to an array of PersonCreateRequest objects. However, this approach clashes with the ROCC schemas that says that organizerIds should be set to an array of string (Person ID). Here the proposed solution is to update the process that generates the JSON files to do the following:

  1. Create a file persons.json that includes the list of Person object to create. For each Person object, set Person.id to a randomly generated id that follow the expected schemas of Person.id.
  2. Update the Challenge objects so that Challenge.organizerIds include the correct Person IDs.

Extending this approach to all the properties of all the schemas when needed, the resulting JSON files will be compliant with the ROCC schemas.

The script that seeds the data base will then be responsible to replacing "temporary IDs" by "real ID" once the objects have been created. Temporary IDs must only be generated for objects that have their IDs generated by the API service (Grants, Challenges, Persons, etc.).

tschaffter commented 3 years ago

Moved to https://github.com/Sage-Bionetworks/rocc-app/issues/84