Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Schema update for relational data #1709

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ These sections are combined to form the [complete profile](#Example-Profile).
* For a larger profile example see [The schema documentation](user/Schema.md)
* Further examples can be found in [the Examples folder](https://github.com/finos/datahelix/tree/master/examples)

A Beta feature has been developed for generating nested data (as a step towards support for relational data), for further information see [this](RelationalData.md) page.
tjohnson-scottlogic marked this conversation as resolved.
Show resolved Hide resolved

# Fields

Fields are the "slots" of data that can take values. Typical fields might be _email_address_ or _user_id_. By default, any piece of data is valid for a field. This is an example field object for the profile:
Expand Down
69 changes: 68 additions & 1 deletion profile/src/main/resources/profileschema/datahelix.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
"items": {
"$ref": "#/definitions/constraint"
}
},
"relationships": {
"title": "Defines any child objects",
"type": "array",
"items": {
"$ref": "#/definitions/relationship"
}
}
},
"definitions": {
Expand Down Expand Up @@ -947,7 +954,67 @@
"type": "string"
}
}
},
"relationship": {
"title": "Defines any nested child objects",
"type": "object",
"additionalProperties": false,
"required": [
"name"
],
"default": {
"name": "relationshipName",
"type": "string",
"formatting": "",
"unique": false,
"nullable": true
},
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"profileFile": {
"type": "string"
},
"profile": {
"type": "object",
"additionalProperties": false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you 'ref' back to the main schema here? This object should confirm to the profile schema, and can contain relationships itself which isn't represented here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, hadn't realised a relationship could contain another relationship. I can't work out how to refer back to the main schema, but I have added a relationships section at the bottom, which seems to work. Not ideal to have fields, constraints and relationships defined twice though.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do something like this?

...
"profile": {
   "$ref": "#/"
}
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. From how I understand it you have to have some initial entries in the schema first, then they can refer to definitions below. I don't think you can effectively go straight to the definitions. I tried the above anyhow but it didn't work for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed @sl-slaing, our aim is to not change the profile format itself and to fix this in the schema. We also don't want to have fields, constraints and relationships defined in two places. The Recursion section of the JSON Schema Reference should help, just can't figure it out at the moment.

"required": [
"fields"
],
"properties": {
"additionalProperties": false,
"description": {
"title": "A description of what data the sub-profile is modelling",
"type": "string"
},
"fields": {
"title": "The fields that data will be produced for. Field names must begin with an alphabetic character.",
"type": "array",
"minItems": 1,
"uniqueItems": true,
"additionalItems": false,
"items": {
"$ref": "#/definitions/field"
}
},
"constraints": {
"title": "The constraints on the data to be output",
"type": "array",
"additionalItems": false,
"items": {
"$ref": "#/definitions/constraint"
}
}
}
},
"extents": {
"type": "array"
}
}
}
}
}