diff --git a/README.md b/README.md index 9d02ef6..c3181ab 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ This repository contains the ICAR ADE work-in-progress JSON standard. This page describes the principles driving this standard. If you want to use the ICAR ADE standard in your application, there are tips and tricks in the [Using the standard](https://github.com/adewg/ICAR/blob/master/Using%20the%20standard.md) file. For a quick start, open the -[exampleUrlScheme.yaml](https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/exampleUrlScheme.yaml) file in +[exampleUrlScheme.json](https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/exampleUrlScheme.json) file in your favorite OpenAPI Specification editor, or use the following URL to have a preview in the free Redoc tool: [view -exampleUrlScheme.yaml](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/exampleUrlScheme.yaml) +exampleUrlScheme.json](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/exampleUrlScheme.json) Approach diff --git a/Release Candidate Messages/exampleErrorResource.json b/Release Candidate Messages/exampleErrorResource.json index dd14239..ab2f163 100644 --- a/Release Candidate Messages/exampleErrorResource.json +++ b/Release Candidate Messages/exampleErrorResource.json @@ -1,28 +1,34 @@ { - "id": { - "type": "string", - "description": "A unique identifier for this particular occurrence of the problem" - }, - "status": { - "type": "integer", - "description": "The HTTP status code applicable to this problem, expressed as a string value", - "format": "int32" - }, - "code": { - "type": "string", - "description": "An application-specific error code, expressed as a string value." - }, - "title":{ - "type": "string", - "description": "A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization." - }, - "detail": { - "type": "string", - "description": "A human-readable explanation specific to this occurrence of the problem. Like title, this field’s value can be localized." - }, - "meta": { - "type": "object", - "properties": "{}" - }, - "description": "A human-readable error message describing what went wrong." + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "A unique identifier for this particular occurrence of the problem" + }, + "status": { + "type": "integer", + "description": "The HTTP status code applicable to this problem, expressed as a string value", + "format": "int32" + }, + "code": { + "type": "string", + "description": "An application-specific error code, expressed as a string value." + }, + "title": { + "type": "string", + "description": "A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization." + }, + "detail": { + "type": "string", + "description": "A human-readable explanation specific to this occurrence of the problem. Like title, this field’s value can be localized." + }, + "meta": { + "type": "object", + "properties": { + + } + } + }, + "description": "A human-readable error message describing what went wrong." } + diff --git a/Release Candidate Messages/exampleUrlScheme.json b/Release Candidate Messages/exampleUrlScheme.json new file mode 100644 index 0000000..2d562a7 --- /dev/null +++ b/Release Candidate Messages/exampleUrlScheme.json @@ -0,0 +1,177 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Release Candidate Messages", + "description": "The specifications of messages which are ready for ICAR approval and release", + "version": "1.0", + "contact" : { + "name": "Animal Data Exchange Working Group", + "url": "https://www.icar.org/index.php/technical-bodies/working-groups/animal-data-exchange-wg/", + "email": "icar@icar.org" + } + }, + "servers": [ + { + "url": "http://example.com" + } + ], + "tags" : [ + { + "name" : "release-candidate", + "description" : "approved by the working group, waiting for a test" + } + ], + "paths": { + "/locations/{location-scheme}/{location-id}/milking-visits": { + "get": { + "operationId" : "get-milking-visits", + "summary": "Get the data for milking visits", + "description": "# Purpose\nProvides data from visits of animals to a milking parlour\n", + "tags": [ "release-candidate"], + "parameters": [ + { + "name": "location-scheme", + "in": "path", + "description": "The scheme id for the location identifier.", + "required": true, + "schema": { + "type": "string", + "enum": [ + "nl.ubn", + "de.farmid", + "be.pen" + ] + } + }, + { + "name": "location-id", + "in": "path", + "description": "The unique identifier for the location.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "start-date-time", + "in": "query", + "description": "The start of the date-time range for the data to get in the request.", + "schema": { + "type": "string", + "format": "date-time" + } + }, + { + "name": "end-date-time", + "in": "query", + "description": "The end of the date-time range for the data to get in the request.", + "schema": { + "type": "string", + "format": "date-time" + } + } + ], + "responses": { + "201": { + "description": "Successful. The response contains the milking results for the given location", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/icarMilkingVisitsResponse" + } + } + } + }, + "default": { + "description": "An error has occured while handling the request. Check the content of the message for the error details.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/error" + } + } + }, + "description": "A default response containing only a list of errors" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "responseErrors": { + "type": "object", + "properties": { + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/error" + } + } + } + }, + "responseMetaData": { + "type": "object", + "properties": { + "metaData": { + "$ref": "#/components/schemas/metaData" + } + } + }, + "error": { + "type": "object", + "properties": { + "data": { + "$ref": "exampleErrorResource.json" + } + } + }, + "metaData": { + "required": [ + "source" + ], + "type": "object", + "properties": { + "data": { + "$ref": "icarMetaDataResource.json" + } + } + }, + "icarMilkingVisitsResponse": { + "type": "array", + "items": { + "$ref": "#/components/schemas/icarMilkingVisitsResponseDataSources" + } + }, + "icarMilkingVisitsResponseDataSources": { + "allOf": [ + { + "$ref": "#/components/schemas/responseMetaData" + }, + { + "$ref": "#/components/schemas/responseErrors" + }, + { + "$ref": "#/components/schemas/icarMilkingVisitsResponseDataSource" + } + ] + }, + "icarMilkingVisitsResponseDataSource": { + "type": "object", + "properties": { + "data": { + "$ref": "icarMilkingVisitResource.json" + } + } + } + } + } +} diff --git a/Release Candidate Messages/exampleUrlScheme.yaml b/Release Candidate Messages/exampleUrlScheme.yaml deleted file mode 100644 index 1f470f2..0000000 --- a/Release Candidate Messages/exampleUrlScheme.yaml +++ /dev/null @@ -1,105 +0,0 @@ -openapi: 3.0.1 -info: - title: Release Candidate Messages - description: | - The specifications of messages which are ready for ICAR approval and release - version: '1.0' -servers: - - url: / -paths: - '/locations/{location-scheme}/{location-id}/milking-visits': - get: - summary: Get the data for milking visits - description: | - # Purpose - Provides data from visits of animals to a milking parlour - parameters: - - name: location-scheme - in: path - description: The scheme id for the location identifier. - required: true - schema: - type: string - enum: - - nl.ubn - - de.farmid - - be.pen - - name: location-id - in: path - description: The unique identifier for the location. - required: true - schema: - type: string - - name: start-date-time - in: query - description: The start of the date-time range for the data to get in the request. - schema: - type: string - format: date-time - - name: end-date-time - in: query - description: The end of the date-time range for the data to get in the request. - schema: - type: string - format: date-time - responses: - '201': - description: Successful. The response contains the milking results for the given location - content: - application/json: - schema: - $ref: '#/components/schemas/icarMilkingVisitsResponse' - default: - description: An error has occured while handling the request. Check the content of the message for the error details. - content: - application/json: - schema: - type: object - properties: - errors: - type: array - items: - $ref: '#/components/schemas/error' - description: A default response containing only a list of errors - -components: - schemas: - responseErrors: - type: object - properties: - errors: - type: array - items: - $ref: '#/components/schemas/error' - responseMetaData: - type: object - properties: - metaData: - $ref: '#/components/schemas/metaData' - error: - type: object - properties: - data: - $ref: 'https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/exampleErrorResource.json' - metaData: - required: - - source - type: object - properties: - data: - $ref: 'https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMetaDataResource.json' - icarMilkingVisitsResponse: - type: array - items: - $ref: '#/components/schemas/icarMilkingVisitsResponseDataSources' - icarMilkingVisitsResponseDataSources: - allOf: - - $ref: '#/components/schemas/responseMetaData' - - $ref: '#/components/schemas/responseErrors' - - $ref: '#/components/schemas/icarMilkingVisitsResponseDataSource' - icarMilkingVisitsResponseDataSource: - type: object - properties: - data: - $ref: 'https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkingVisitResource.json' - diff --git a/Release Candidate Messages/icarAnimalIdSchemeCode.json b/Release Candidate Messages/icarAnimalIdSchemeCode.json index 127d6c1..c13dc11 100644 --- a/Release Candidate Messages/icarAnimalIdSchemeCode.json +++ b/Release Candidate Messages/icarAnimalIdSchemeCode.json @@ -2,7 +2,7 @@ "type": "string", "description": "Identifies the used scheme for an animal identification string. nl-v1 life numbers are formatted as NL 123456789. See https://www.rvo.nl/onderwerpen/agrarisch-ondernemen/dieren/dieren-registreren/runderen/oormerken-voor-runderen for more information.", "enum": [ - "nl-v1", - "be-v1" + "nl.ubn", + "be.pen" ] } diff --git a/Release Candidate Messages/icarEventCoreResource.json b/Release Candidate Messages/icarEventCoreResource.json index fe01f39..2bd5a75 100644 --- a/Release Candidate Messages/icarEventCoreResource.json +++ b/Release Candidate Messages/icarEventCoreResource.json @@ -1,6 +1,4 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "required": [ "id", "animal", diff --git a/Release Candidate Messages/icarIdentifierType.json b/Release Candidate Messages/icarIdentifierType.json index 9b669f2..ec3c38a 100644 --- a/Release Candidate Messages/icarIdentifierType.json +++ b/Release Candidate Messages/icarIdentifierType.json @@ -1,6 +1,4 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "required": [ "id", "scheme" diff --git a/Release Candidate Messages/icarLocationIdentifierType.json b/Release Candidate Messages/icarLocationIdentifierType.json index 7cee255..8442c1c 100644 --- a/Release Candidate Messages/icarLocationIdentifierType.json +++ b/Release Candidate Messages/icarLocationIdentifierType.json @@ -1,6 +1,4 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "$ref": "icarIdentifierType.json", "description": "Location identifier based on a scheme and ID." } diff --git a/Release Candidate Messages/icarMetaDataResource.json b/Release Candidate Messages/icarMetaDataResource.json index c650aff..a587a5b 100644 --- a/Release Candidate Messages/icarMetaDataResource.json +++ b/Release Candidate Messages/icarMetaDataResource.json @@ -1,22 +1,27 @@ { + "type": "object", + "properties": { + "source": { "type": "string", "description": "Source where data is retrieved from. URI that identified the source system" }, "modified": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarDateTimeType.json" + "$ref": "icarDateTimeType.json" }, "created": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarDateTimeType.json" + "$ref": "icarDateTimeType.json" }, "creator": { "type": "string", "description": "Person or organisation who created the object" }, "validFrom": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarDateTimeType.json" + "$ref": "icarDateTimeType.json" }, "validTo": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarDateTimeType.json" + "$ref": "icarDateTimeType.json" } + }, + "description": "Generic meta data on this event" } diff --git a/Release Candidate Messages/icarMilkingExceptionCode.json b/Release Candidate Messages/icarMilkingExceptionCode.json deleted file mode 100644 index 9a9fd01..0000000 --- a/Release Candidate Messages/icarMilkingExceptionCode.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "string", - "description": "The exception code indicating why the milking was unsuccessfull", - "enum": [ - "0", - "1", - "2", - "3", - "4", - "5" - ] -} diff --git a/Release Candidate Messages/icarMilkingSuccessType.json b/Release Candidate Messages/icarMilkingSuccessType.json deleted file mode 100644 index dd97725..0000000 --- a/Release Candidate Messages/icarMilkingSuccessType.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "boolean" -} diff --git a/Release Candidate Messages/icarMilkingVisitResource.json b/Release Candidate Messages/icarMilkingVisitResource.json index 0ba2cce..43a135c 100644 --- a/Release Candidate Messages/icarMilkingVisitResource.json +++ b/Release Candidate Messages/icarMilkingVisitResource.json @@ -1,6 +1,4 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "required": [ "id", "animal", @@ -17,25 +15,23 @@ { "properties": { "milkingStartingDateTime": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarDateTimeType.json" + "$ref": "icarDateTimeType.json" }, "milkingDuration": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkDurationType.json" + "$ref": "icarMilkDurationType.json" }, "milkingVisitDuration": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkDurationType.json" + "$ref": "icarMilkDurationType.json" }, "milkingType": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkingTypeCode.json" + "$ref": "icarMilkingTypeCode.json" }, "milkingMilkWeight": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkingMilkWeightType.json" - }, - "milkingSuccess": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkingSuccessType.json" + "$ref": "icarMilkingMilkWeightType.json" }, - "milkingExceptionCode": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkingExceptionCode.json" + "milkingComplete": { + "type": "boolean", + "description": "indication whether this milking was completed normally" }, "milkingParlourUnit": { "type": "string", @@ -56,19 +52,19 @@ "quarterMilkings": { "type": "array", "items": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarQuarterMilkingType.json" + "$ref": "icarQuarterMilkingType.json" } }, "animalMilkingSample": { "type": "array", "items": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarAnimalMilkingSampleType.json" + "$ref": "icarAnimalMilkingSampleType.json" } }, "icarMilkCharacteristicsTypes": { "type": "array", "items": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkCharacteristicsType.json" + "$ref": "icarMilkCharacteristicsType.json" } } } diff --git a/Release Candidate Messages/icarQuarterMilkingType.json b/Release Candidate Messages/icarQuarterMilkingType.json index f0c437b..50d2f15 100644 --- a/Release Candidate Messages/icarQuarterMilkingType.json +++ b/Release Candidate Messages/icarQuarterMilkingType.json @@ -11,21 +11,21 @@ "RB" ] }, "quarterMilkingDuration": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkDurationType.json" + "$ref": "icarMilkDurationType.json" }, "quarterMilkingWeight": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkingMilkWeightType.json" + "$ref": "icarMilkingMilkWeightType.json" }, "icarQuarterMilkingSample": { "type": "array", "items": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarQuarterMilkingSampleType.json" + "$ref": "icarQuarterMilkingSampleType.json" } }, "icarQuarterCharacteristics": { "type": "array", "items": { - "$ref": "https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/icarMilkCharacteristicsType.json" + "$ref": "icarMilkCharacteristicsType.json" } } } diff --git a/Using the standard.md b/Using the standard.md index 054c53a..0cede4e 100644 --- a/Using the standard.md +++ b/Using the standard.md @@ -6,10 +6,10 @@ The ADE standard is meant to be an open standard. As such, you are free to start The standard currently focuses on JSON messages defined in JSON Schema. These messages can be transported via REST or via any other channel. We are also working on a recommended URL scheme if you want to use REST. For now, you can find an example URL scheme to help you navigate and decide how to use the standard. This scheme is defined in the OpenAPI Specification v3. ## Getting Started -Most developers should be familiar with REST and JSON files. To simply view the standard, you can open the [exampleUrlScheme.yaml](https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/exampleUrlScheme.yaml) file in your favorite OpenAPI Specification editor. +Most developers should be familiar with REST and JSON files. To simply view the standard, you can open the [exampleUrlScheme.json](https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/exampleUrlScheme.json) file in your favorite OpenAPI Specification editor. Or, for convenience, use the following URL to have a preview in the free Redoc tool: -[view exampleUrlScheme.yaml](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/exampleUrlScheme.yaml) +[view exampleUrlScheme.json](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/adewg/ICAR/master/Release%20Candidate%20Messages/exampleUrlScheme.json) ## Customizing the Standard The standard aims to cover most cases in a generic way. However, there will always be regional differences or vendor specific fields that may be required to be part of a message. You are free to simply add more fields to your messages than described in the standard. When doing so, please take note of the following recommendations: