Add voucher schema

This commit is contained in:
lash 2023-03-05 11:18:41 +00:00
parent ccec034d3a
commit 85c7940413
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
7 changed files with 78 additions and 5 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
cic.json
out

View File

@ -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

View File

@ -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()

View File

@ -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"]
}

View File

@ -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"]
}
]
}

View File

@ -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",

19
voucher.in.json Normal file
View File

@ -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"]
}