Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add locations resource #126

Merged
merged 4 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 21 additions & 0 deletions collections/icarLocationCollection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"description": "Represents a collection of locations. Based on icarResourceCollection to provide paging etc.",

"allOf": [{
"$ref": "../collections/icarResourceCollection.json"
},
{
"type": "object",

"properties": {
"member": {
"type": "array",
"items": {
"$ref": "../resources/icarLocationResource.json"
},
"description": "As per JSON-LD Hydra syntax, member provides the array of objects, in this case locations."
}
}
}
]
}
32 changes: 32 additions & 0 deletions resources/icarLocationResource.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"description": "An location scheme / location id combinations.",

"allOf": [{
"$ref": "./icarResource.json",
}, {
"type": "object",

"required": [
"identifier"
],

"properties": {
"identifier": {
"$ref": "../types/icarLocationIdentifierType.json",
"description": "Unique location scheme and identifier combination."
},
"alternativeIdentifiers": {
"type": "array",
"items": {
"$ref": "../types/icarLocationIdentifierType.json"
},
"description": "Alternative identifiers for the location. Must be a 1:1 mapping, meaning that when querying resources with an alternative identifier (instead of the 'main' identifier), the response may not be different."
},
"name": {
"type": "string",
"description": "The human readable name of the location."
}
}
}
]
}
59 changes: 59 additions & 0 deletions url-schemes/exampleUrlScheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,36 @@
}
],
"paths": {
"/locations": {
"get": {
"operationId": "get-locations",
"summary": "Get available schema/id combinations for locations.",
"description": "# Purpose\nProvide a list of available locations.\nShould return only those combinations the user currently logged in has access to.",
"tags": [
"additions"
],
"responses": {
"200": {
"description": "Successful. The response contains the available locations.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/icarLocationCollection"
},
"examples": {
"base": {
"$ref": "#/components/examples/locations"
}
}
}
}
},
"default": {
"$ref": "#/components/responses/default"
}
}
}
},
"/locations/{location-scheme}/{location-id}/milking-visits": {
"get": {
"operationId": "get-milking-visits",
Expand Down Expand Up @@ -708,6 +738,9 @@
"error": {
"$ref": "../resources/exampleErrorResource.json"
},
"icarLocationCollection": {
"$ref": "../collections/icarLocationCollection.json"
},
"icarMilkingVisitEventCollection": {
"$ref": "../collections/icarMilkingVisitEventCollection.json"
},
Expand Down Expand Up @@ -825,6 +858,32 @@
}
},
"examples": {
"locations": {
"value": {
"view": {
"totalItems": 1,
"totalPages": 1,
"pageSize": 10,
"currentPage": 1
},
"member": [{
"identifier": {
"id": "276031231231234",
"schema": "eu.farmId"
},
"name": "My little farm",
"meta": {
"source": "source",
"creator": "creator",
"modified": "2020-01-29T08:49:06.1314223+00:00",
"created": "2020-01-29T08:49:06.1314223+00:00",
"validFrom": null,
"validTo": null
}
}
],
}
},
"arrival": {
"value": {
"view": {
Expand Down