diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e79a01 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +cic.json diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..71027a4 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +all: + python bundle.py > cic.json + + +test: all + check-jsonschema --schemafile cic.json test_valid.json diff --git a/bundle.py b/bundle.py new file mode 100644 index 0000000..7eedf78 --- /dev/null +++ b/bundle.py @@ -0,0 +1,38 @@ +# standard imports +import json +import os + + +fp = os.path.join('.', 'cic.in.json') +f = open(fp, 'r') +o = json.load(f) + +fp = os.path.join('.', 'mime.in.json') +f = open(fp, 'r') +o_mime = json.load(f) +o['mime'] = o_mime + + +fp = os.path.join('.', 'opensea_part.in.json') +f = open(fp, 'r') +o_opensea = json.load(f) +for k in o_opensea['properties'].keys(): + p = {} + for v in o_opensea['properties'][k]: + p[v] = o_opensea['properties'][k][v] + o['properties'][k] = p +o['required'] += o_opensea['required'] +o['oneOf'] = o_opensea['oneOf'] + + +fp = os.path.join('.', 'nft.in.json') +f = open(fp, 'r') +o_nft = json.load(f) +for k in o_nft['properties'].keys(): + p = {} + for v in o_nft['properties'][k]: + p[v] = o_nft['properties'][k][v] + o['properties'][k] = p + + +print(json.dumps(o)) diff --git a/cic.in.json b/cic.in.json new file mode 100644 index 0000000..02d24c6 --- /dev/null +++ b/cic.in.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "sha256:", + "title": "CIC core metadata container", + + "type": "object", + "properties": { + "targets": { + "type": "array", + "items": { + "type": "string", + "pattern": "^(0x)?[a-fA-F0-9]{40}" + } + + }, + "attachments": { + "type": "array", + "items": { + "$ref": "/mime" + } + } + }, + "required": ["targets", "attachments"] +} diff --git a/cic.json b/cic.json deleted file mode 100644 index 0b8400e..0000000 --- a/cic.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "sha256:", - "title": "CIC core metadata container", - - "type": "object", - "properties": { - "targets": { - "type": "array", - "items": { - "type": "string", - "pattern": "^(0x)?[a-fA-F0-9]{40}" - } - - }, - "attachments": { - "type": "array", - "items": { - "$ref": "/mime" - } - } - }, - "required": ["targets", "attachments"], - "jsonmime": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "/mime", - "title": "A single generic attachment for documenting any asset", - - "type": "object", - "properties": { - "contentType": { - "type": "string", - "$comment": "valid mime type" - }, - "contentTransferEncoding": { - "type": "string", - "enum": ["BASE64", "QUOTED-PRINTABLE", "8BIT", "7BIT"] - }, - "subject": { - "type": "string", - "$comment": "utf-8" - }, - "body": { - "type": "string", - "$comment": "uri including dataurl" - } - }, - "required": ["contentType", "body", "subject"] - } -} diff --git a/jsonmime.json b/mime.in.json similarity index 100% rename from jsonmime.json rename to mime.in.json diff --git a/nft.json b/nft.in.json similarity index 100% rename from nft.json rename to nft.in.json diff --git a/opensea_part.json b/opensea_part.in.json similarity index 100% rename from opensea_part.json rename to opensea_part.in.json