Skip to content

Commit b1b1aaa

Browse files
authored
Merge pull request #30 from c2pa-org/adam-gol/issue16
Implement github action to lint and validate JSON files
2 parents 686203a + 6dd8716 commit b1b1aaa

File tree

2 files changed

+135
-99
lines changed

2 files changed

+135
-99
lines changed

.github/workflows/validate-json.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: JSON Schema Validation
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
validate-json:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Install sourcemeta json schema cli
18+
uses: sourcemeta/jsonschema@main
19+
20+
- name: Lint JSON files
21+
run: |
22+
echo "Linting softbinding-algorithm-entry-schema.json..."
23+
set -e # Exit on any error
24+
jsonschema lint softbinding-algorithm-entry-schema.json
25+
echo "✓ softbinding-algorithm-entry-schema.json passed linting"
26+
27+
- name: Validate against schema
28+
run: |
29+
echo "Validating softbinding-algorithm-list.json against schema..."
30+
set -e # Exit on any error
31+
jsonschema validate softbinding-algorithm-entry-schema.json softbinding-algorithm-list.json
32+
echo "✓ softbinding-algorithm-list.json is valid against the schema"
Lines changed: 103 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,114 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"type": "object",
4-
"properties": {
5-
"identifier": {
6-
"type": "integer",
7-
"minimum": 0,
8-
"maximum": 65535,
9-
"description": "This identifier will be assigned when the soft binding algorithm is added to the list."
10-
},
11-
"deprecated": {
12-
"type": "boolean",
13-
"default": false,
14-
"description": "Indicates whether this soft binding algorithm is deprecated. Deprecated algorithms shall not be used for creating soft bindings. Deprecated algorithms may be used for resolving soft bindings but this behaviour is discouraged."
15-
},
16-
"alg": {
17-
"type": "string",
18-
"pattern": "(c2pa\\.|[A-Za-z0-9\\-\\.]+)",
19-
"description": "Entity-specific namespace as specified for C2PA Assertions labels that shall begin with the Internet domain name for the entity similar to how Java packages are defined (e.g., `com.example.algo1`, `net.example.algos.algo2`)"
20-
},
21-
"type": {
22-
"type": "string",
23-
"enum": [
24-
"watermark",
25-
"fingerprint"
26-
],
27-
"description": "Type of soft binding implemented by this algorithm."
28-
},
29-
"decodedMediaTypes": {
30-
"type": "array",
31-
"minItems": 1,
32-
"items": {
3+
"$id": "https://spec.c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html",
4+
"type": "array",
5+
"items": {
6+
"type": "object",
7+
"properties": {
8+
"identifier": {
9+
"type": "integer",
10+
"minimum": 0,
11+
"maximum": 65535,
12+
"description": "This identifier will be assigned when the soft binding algorithm is added to the list."
13+
},
14+
"deprecated": {
15+
"type": "boolean",
16+
"default": false,
17+
"description": "Indicates whether this soft binding algorithm is deprecated. Deprecated algorithms shall not be used for creating soft bindings. Deprecated algorithms may be used for resolving soft bindings but this behaviour is discouraged."
18+
},
19+
"alg": {
3320
"type": "string",
21+
"pattern": "(c2pa\\.|[A-Za-z0-9\\-\\.]+)",
22+
"description": "Entity-specific namespace as specified for C2PA Assertions labels that shall begin with the Internet domain name for the entity similar to how Java packages are defined (e.g., `com.example.algo1`, `net.example.algos.algo2`)"
23+
},
24+
"type": {
3425
"enum": [
35-
"application",
36-
"audio",
37-
"image",
38-
"model",
39-
"text",
40-
"video"
26+
"watermark",
27+
"fingerprint"
4128
],
42-
"description": "IANA top level media type (rendered) for which this soft binding algorithm applies."
43-
}
44-
},
45-
"encodedMediaTypes": {
46-
"type": "array",
47-
"minItems": 1,
48-
"items": {
49-
"type": "string",
50-
"description": "IANA media type for which this soft binding algorithm applies, e.g., application/pdf",
51-
"pattern": "^([a-zA-Z0-9\\-]+\\/[a-zA-Z0-9\\-\\+]+(?:\\.[a-zA-Z0-9\\-\\+]+)*)$"
52-
}
53-
},
54-
"entryMetadata": {
55-
"type": "object",
56-
"properties": {
57-
"description": {
58-
"type": "string",
59-
"description": "Human readable description of the algorithm."
60-
},
61-
"dateEntered": {
29+
"description": "Type of soft binding implemented by this algorithm."
30+
},
31+
"decodedMediaTypes": {
32+
"type": "array",
33+
"minItems": 1,
34+
"items": {
35+
"enum": [
36+
"application",
37+
"audio",
38+
"image",
39+
"model",
40+
"text",
41+
"video"
42+
],
43+
"description": "IANA top level media type (rendered) for which this soft binding algorithm applies."
44+
}
45+
},
46+
"encodedMediaTypes": {
47+
"type": "array",
48+
"minItems": 1,
49+
"items": {
6250
"type": "string",
63-
"format": "date-time",
64-
"description": "Date of entry for this algorithm."
51+
"description": "IANA media type for which this soft binding algorithm applies, e.g., application/pdf",
52+
"pattern": "^([a-zA-Z0-9\\-]+\\/[a-zA-Z0-9\\-\\+]+(?:\\.[a-zA-Z0-9\\-\\+]+)*)$"
53+
}
54+
},
55+
"entryMetadata": {
56+
"type": "object",
57+
"properties": {
58+
"description": {
59+
"type": "string",
60+
"description": "Human readable description of the algorithm."
61+
},
62+
"dateEntered": {
63+
"type": "string",
64+
"format": "date-time",
65+
"description": "Date of entry for this algorithm."
66+
},
67+
"contact": {
68+
"type": "string",
69+
"format": "email"
70+
},
71+
"informationalUrl": {
72+
"type": "string",
73+
"format": "uri",
74+
"description": "A web page containing more details about the algorithm."
75+
}
6576
},
66-
"contact": {
77+
"required": [
78+
"description",
79+
"dateEntered",
80+
"contact",
81+
"informationalUrl"
82+
]
83+
},
84+
"softBindingResolutionApis": {
85+
"type": "array",
86+
"items": {
6787
"type": "string",
68-
"format": "email"
88+
"format": "uri"
6989
},
70-
"informationalUrl": {
71-
"type": "string",
72-
"format": "uri",
73-
"description": "A web page containing more details about the algorithm."
74-
}
75-
},
76-
"required": [
77-
"description",
78-
"dateEntered",
79-
"contact",
80-
"informationalUrl"
81-
]
90+
"description": "A list of Soft Binding Resolution APIs supporting this algorithm."
91+
}
8292
},
83-
"softBindingResolutionApis": {
84-
"type": "array",
85-
"items": {
86-
"type": "string",
87-
"format": "uri"
93+
"oneOf": [
94+
{
95+
"required": ["decodedMediaTypes"],
96+
"not": {
97+
"required": ["encodedMediaTypes"]
98+
}
8899
},
89-
"description": "A list of Soft Binding Resolution APIs supporting this algorithm."
90-
}
91-
},
92-
"required": [
93-
"identifier",
94-
"alg",
95-
"type",
96-
"entryMetadata"
97-
],
98-
"oneOf": [
99-
{
100-
"required": [
101-
"decodedMediaTypes"
102-
]
103-
},
104-
{
105-
"required": [
106-
"encodedMediaTypes"
107-
]
108-
}
109-
]
110-
}
100+
{
101+
"required": ["encodedMediaTypes"],
102+
"not": {
103+
"required": ["decodedMediaTypes"]
104+
}
105+
}
106+
],
107+
"required": [
108+
"identifier",
109+
"alg",
110+
"type",
111+
"entryMetadata"
112+
]
113+
}
114+
}

0 commit comments

Comments
 (0)