Skip to content

Commit

Permalink
Add inversedby example & add missing cascade & fix example.json $ref
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoLouwerse committed Jun 26, 2023
1 parent 2bb0d50 commit 7b062e7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Installation/Action/ps.EmailActionExample.action.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"$id": "https://example.com/action/ps.EmailActionExample.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.1",
"description": "This is an example Action. This action is triggered when commongateway.object.create event is thrown and the data (object) of the event has entity = https://example.com/example.schema.json. In order for this condition to work the ref https://example.com/example.schema.json has to be translated to an id, see installation.json['actions']['fixConfigRef'] for how to do this.",
"description": "This is an example Action. This action is triggered when commongateway.object.create event is thrown and the data (object) of the event has entity = https://example.com/schema/example.schema.json. In order for this condition to work the ref https://example.com/schema/example.schema.json has to be translated to an id, see installation.json['actions']['fixConfigRef'] for how to do this.",
"listens": [
"commongateway.object.pre.create"
],
Expand All @@ -12,7 +12,7 @@
"==": [
{
"var": "entity"
}, "https://example.com/example.schema.json"
}, "https://example.com/schema/example.schema.json"
]
},
"class": "App\\ActionHandler\\EmailHandler",
Expand Down
2 changes: 1 addition & 1 deletion Installation/Data/data.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"https://example.com/example.schema.json": [
"https://example.com/schema/example.schema.json": [
{
"id": "382fc3a3-f84e-4e7a-bd09-ecf69951d035",
"firstName": "John",
Expand Down
2 changes: 1 addition & 1 deletion Installation/Data/exampleTestData.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"https://example.com/example.schema.json": [
"https://example.com/schema/example.schema.json": [
{
"id": "906bd169-0256-433d-87be-4ed393a9511c",
"firstName": "John",
Expand Down
11 changes: 7 additions & 4 deletions Installation/Schema/example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$id": "https://example.com/example.schema.json",
"$id": "https://example.com/schema/example.schema.json",
"$schema": "https://docs.commongateway.nl/schemas/Entity.schema.json",
"version": "0.2",
"title": "Example",
Expand Down Expand Up @@ -29,16 +29,19 @@
"description": "A description of this Example object"
},
"relationExample": {
"description": "An example of a relation to another Schema",
"description": "An example of an inversed by relation to another Schema",
"example": "{ \"postalCode\": \"1234AB\", \"notes\": [\"note1\", \"note2\"] }",
"$ref": "https://example.com/schema/relationExample.schema.json"
"$ref": "https://example.com/schema/relationExample.schema.json",
"inversedBy": "example",
"cascade": true
},
"relationExamples": {
"type": "array",
"description": "An example of an array of objects",
"items": {
"$ref": "https://example.com/schema/relationExample.schema.json"
}
},
"cascade": true
}
}
}
9 changes: 8 additions & 1 deletion Installation/Schema/relationExample.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.1",
"title": "RelationExample",
"type": "object",
"description": "An example Schema object. This Schema is used to show how a relation between Schemas works in the Schema: https://example.com/example.schema.json.",
"description": "An example Schema object. This Schema is used to show how a relation between Schemas works in the Schema: https://example.com/schema/example.schema.json.",
"properties": {
"postalCode": {
"type": "string",
Expand All @@ -19,6 +19,13 @@
"items": {
"type": "string"
}
},
"example": {
"description": "An example of an inversed by relation to another Schema",
"example": "{ \"firstName\": \"John\", \"lastName\": \"Doe\" }",
"$ref": "https://example.com/schema/example.schema.json",
"inversedBy": "relationExample",
"cascade": true
}
}
}
6 changes: 3 additions & 3 deletions Installation/installation.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
],
"cards": {
"schemas": [
"https://example.com/example.schema.json"
"https://example.com/schema/example.schema.json"
],
"collections": [
"https://example.com/collection/ps.default.collection.json"
Expand Down Expand Up @@ -68,7 +68,7 @@
"name": "Search",
"description": "Generic Search Endpoint. This is an example of an Endpoint using multiple schemas, this way it is possible to get data of multiple schemas.",
"schemas": [
"https://example.com/example.schema.json",
"https://example.com/schema/example.schema.json",
"https://example.com/schema/relationExample.schema.json"
],
"path": ["search"],
Expand All @@ -78,7 +78,7 @@
],
"schemas": [
{
"reference": "https://example.com/example.schema.json",
"reference": "https://example.com/schema/example.schema.json",
"description": "An example for the following endpoint: /api/examples. methods: [] stands for 'All methods are allowed'. This endpoint also has 2 sub endpoint examples, a subSchemaEndpoint and a subEndpoint.",
"path": "examples",
"methods": [],
Expand Down

0 comments on commit 7b062e7

Please sign in to comment.