diff --git a/.gitignore b/.gitignore index 1e79a01..f7c61bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ cic.json +out diff --git a/Makefile b/Makefile index d41005b..3a3a034 100644 --- a/Makefile +++ b/Makefile @@ -5,4 +5,5 @@ build: test: build - check-jsonschema --schemafile cic.json test_valid.json + check-jsonschema --schemafile out/cic.json test_valid.json + check-jsonschema --schemafile out/voucher.json test_valid.json diff --git a/bundle.py b/bundle.py index 7eedf78..eb6c199 100644 --- a/bundle.py +++ b/bundle.py @@ -35,4 +35,23 @@ for k in o_nft['properties'].keys(): o['properties'][k] = p -print(json.dumps(o)) +os.makedirs('out', exist_ok=True) + +fp = os.path.join('out', 'cic.json') +f = open(fp, 'w') +json.dump(o, f) +f.close() + +fp = os.path.join('.', 'voucher.in.json') +f = open(fp, 'r') +o_voucher = json.load(f) +for k in o_voucher['properties'].keys(): + p = {} + for v in o_voucher['properties'][k]: + p[v] = o_voucher['properties'][k][v] + o['properties'][k] = p + +fp = os.path.join('out', 'voucher.json') +f = open(fp, 'w') +json.dump(o, f) +f.close() diff --git a/cic.in.json b/cic.in.json index 6b92702..4655496 100644 --- a/cic.in.json +++ b/cic.in.json @@ -1,10 +1,21 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "sha256:", "title": "CIC core metadata container", + "$id": "/cic/core", "type": "object", "properties": { + "version": { + "type": "integer" + }, + "validFrom": { + "type": "string", + "format": "date-time" + }, + "validUntil": { + "type": "string", + "format": "date-time" + }, "targets": { "type": "array", "items": { @@ -27,5 +38,5 @@ } } }, - "required": ["targets", "attachments", "txs"] + "required": ["targets", "attachments", "txs", "validFrom"] } diff --git a/mime.in.json b/mime.in.json index ec18a85..440e1d2 100644 --- a/mime.in.json +++ b/mime.in.json @@ -20,7 +20,19 @@ "body": { "type": "string", "$comment": "uri including dataurl" + }, + "ref": { + "type": "string", + "format": "uri" } }, - "required": ["contentType", "body", "subject"] + "required": ["contentType", "subject"], + "oneOf": [ + { + "required": ["body"] + }, + { + "required": ["ref"] + } + ] } diff --git a/test_valid.json b/test_valid.json index 46f527b..c4892ee 100644 --- a/test_valid.json +++ b/test_valid.json @@ -5,6 +5,10 @@ "0xabcdef0123456789abcdef0123456789abcdef00", "abcdef0123456789abcdef0123456789abcdef00" ], + "validFrom": "2023-03-05T10:46:05+00:00", + "validUntil": "2024-03-05T10:46:05+00:00", + "unitOfAccount": "wampum", + "issuerName": "John Doe", "txs": [ "0xabcdef0123456789abcdef0123456789abcdef00abcdef0123456789abcdef00", "abcdef0123456789abcdef0123456789abcdef00abcdef0123456789abcdef00" @@ -20,6 +24,12 @@ "subject": "some text", "body": "fee fi fo fum" }, + { + "contentType": "text/plain", + "contentTransferEncoding": "7BIT", + "subject": "some text", + "ref": "sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae" + }, { "contentType": "application/pdf", "contentTransferEncoding": "BASE64", diff --git a/voucher.in.json b/voucher.in.json new file mode 100644 index 0000000..380b882 --- /dev/null +++ b/voucher.in.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "/cic/voucher", + "title": "CIC voucher schema extensiom", + + "type": "object", + "properties": { + "unitOfAccount": { + "type": "string" + }, + "issuerName": { + "type": "string" + }, + "namespace": { + "type": "string" + } + }, + "require": ["unitOfAccount", "issuerName"] +}