From d7dfb3dfd4d0a8d9d6ec4cebc1a94c4bb91bb6a9 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Wed, 6 May 2020 11:24:02 +0200 Subject: [PATCH 1/4] Initial expense schema --- examples/expense.json | 9 ++++ schemas/expense.json | 102 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 examples/expense.json create mode 100644 schemas/expense.json diff --git a/examples/expense.json b/examples/expense.json new file mode 100644 index 0000000..2d7e1ee --- /dev/null +++ b/examples/expense.json @@ -0,0 +1,9 @@ +{ + "title": "Server rent", + "description": "Dedicated server: andromeda.kosmos.org, April 2020", + "currency": "EUR", + "amount": 39.00, + "date": "2020-05-06", + "url": "https://wiki.kosmos.org/Infrastructure#Hetzner", + "tags": ["infrastructure", "server", "hetzner"] +} diff --git a/schemas/expense.json b/schemas/expense.json new file mode 100644 index 0000000..8979e2a --- /dev/null +++ b/schemas/expense.json @@ -0,0 +1,102 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "$id": "https://schema.kosmos.org/Expense", + "type": "object", + "title": "Expense", + "description": "Record of costs expended", + "default": {}, + "required": [ + "title", + "currency", + "amount" + ], + "additionalProperties": false, + "properties": { + "@context": { + "type": "string", + "enum": [ "https://schema.kosmos.org" ], + "default": "https://schema.kosmos.org" + }, + "@type": { + "type": "string", + "enum": [ "Expense" ], + "default": "Expense" + }, + "title": { + "type": "string", + "title": "Title", + "description": "A short description of the expense", + "default": "", + "examples": [ + "Server rent" + ] + }, + "description": { + "type": "string", + "title": "Description", + "description": "A longer description of the expense", + "default": "", + "examples": [ + "Dedicated server: andromeda.kosmos.org" + ] + }, + "currency": { + "type": "string", + "title": "Currency", + "description": "ISO 4217 (or other) code of the currency that the expense was paid with", + "default": "", + "examples": [ + "EUR", + "USD", + "BTC" + ] + }, + "amount": { + "type": "number", + "title": "Amount", + "description": "Expended amount of defined currency", + "default": 0, + "examples": [ + 42.0 + ] + }, + "date": { + "type": "string", + "format": "date", + "title": "Date", + "description": "Date of contribution (RFC 3339 full-date)" + }, + "url": { + "type": "string", + "format": "uri", + "title": "URL", + "description": "A URL pointing to more information about the expense or related items", + "default": "", + "examples": [ + "https://wiki.kosmos.org/Infrastructure#Hetzner" + ] + }, + "tags": { + "type": "array", + "title": "Tags", + "description": "Tags for organizing, filtering, sorting, etc.", + "default": [], + "items": { + "$id": "#/properties/tags/items", + "anyOf": [ + { + "$id": "#/properties/tags/items/anyOf/0", + "type": "string", + "title": "Tag", + "description": "A tag (lowercase dasherized)", + "default": "", + "examples": [ + "infrastructure", + "server" + ] + } + ] + } + } + } +} From a41839ed09d8eadd076b384c0c6133acaec0b973 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Wed, 6 May 2020 11:59:36 +0200 Subject: [PATCH 2/4] Fix description --- schemas/expense.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/expense.json b/schemas/expense.json index 8979e2a..2e194a8 100644 --- a/schemas/expense.json +++ b/schemas/expense.json @@ -64,7 +64,7 @@ "type": "string", "format": "date", "title": "Date", - "description": "Date of contribution (RFC 3339 full-date)" + "description": "Date when expense was logged/proposed (RFC 3339 full-date)" }, "url": { "type": "string", From 300eb7f9407c6aaa713957379cd060fc0546f7b7 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Wed, 13 May 2020 16:13:12 +0200 Subject: [PATCH 3/4] Allow additional props, add details prop --- schemas/expense.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/schemas/expense.json b/schemas/expense.json index 2e194a8..f3e0c09 100644 --- a/schemas/expense.json +++ b/schemas/expense.json @@ -10,7 +10,7 @@ "currency", "amount" ], - "additionalProperties": false, + "additionalProperties": true, "properties": { "@context": { "type": "string", @@ -97,6 +97,11 @@ } ] } + }, + "details": { + "type": "object", + "title": "Tag", + "properties": {} } } } From 655e30227b0cf93ce17d8e92bb10c1ee9a3acb58 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Wed, 13 May 2020 16:13:39 +0200 Subject: [PATCH 4/4] Remove IDs --- schemas/expense.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/schemas/expense.json b/schemas/expense.json index f3e0c09..4f27ed1 100644 --- a/schemas/expense.json +++ b/schemas/expense.json @@ -82,10 +82,8 @@ "description": "Tags for organizing, filtering, sorting, etc.", "default": [], "items": { - "$id": "#/properties/tags/items", "anyOf": [ { - "$id": "#/properties/tags/items/anyOf/0", "type": "string", "title": "Tag", "description": "A tag (lowercase dasherized)",