From 8534e1266180bfa5623cacb7fba1a64d09027783 Mon Sep 17 00:00:00 2001 From: Adam Goldberg Date: Thu, 24 Jul 2025 12:15:31 -0400 Subject: [PATCH 1/7] Implement github action to lint and validate JSON files --- .github/workflows/validate-json.yaml | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/validate-json.yaml diff --git a/.github/workflows/validate-json.yaml b/.github/workflows/validate-json.yaml new file mode 100644 index 0000000..9853375 --- /dev/null +++ b/.github/workflows/validate-json.yaml @@ -0,0 +1,37 @@ +name: JSON Schema Validation + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + +jobs: + validate-json: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install sourcemeta json schema cli + uses: sourcemeta/jsonschema@main + + - name: Lint JSON files + run: | + echo "Linting JSON files..." + set -e # Exit on any error + echo "Linting softbinding-algorithm-list.json..." + jsonschema lint softbinding-algorithm-list.json + echo "✓ softbinding-algorithm-list.json passed linting" + + echo "Linting softbinding-algorithm-entry-schema.json..." + jsonschema lint softbinding-algorithm-entry-schema.json + echo "✓ softbinding-algorithm-entry-schema.json passed linting" + + - name: Validate against schema + run: | + echo "Validating softbinding-algorithm-list.json against schema..." + set -e # Exit on any error + jsonschema validate softbinding-algorithm-list.json --schema softbinding-algorithm-entry-schema.json + echo "✓ softbinding-algorithm-list.json is valid against the schema" \ No newline at end of file From 5dc051940ae5eee7a5d28e2f6f49493f9c7905da Mon Sep 17 00:00:00 2001 From: Adam Goldberg Date: Thu, 24 Jul 2025 12:21:17 -0400 Subject: [PATCH 2/7] Don't lint the instance --- .github/workflows/validate-json.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/validate-json.yaml b/.github/workflows/validate-json.yaml index 9853375..7b7953e 100644 --- a/.github/workflows/validate-json.yaml +++ b/.github/workflows/validate-json.yaml @@ -19,13 +19,8 @@ jobs: - name: Lint JSON files run: | - echo "Linting JSON files..." - set -e # Exit on any error - echo "Linting softbinding-algorithm-list.json..." - jsonschema lint softbinding-algorithm-list.json - echo "✓ softbinding-algorithm-list.json passed linting" - echo "Linting softbinding-algorithm-entry-schema.json..." + set -e # Exit on any error jsonschema lint softbinding-algorithm-entry-schema.json echo "✓ softbinding-algorithm-entry-schema.json passed linting" From aee2331a575548a22b76e6261a22665427083477 Mon Sep 17 00:00:00 2001 From: Adam Goldberg Date: Thu, 24 Jul 2025 12:25:29 -0400 Subject: [PATCH 3/7] Remove unnecessary "type" of "string" for enums that consist of solely strings. "Setting `type` alongside `enum` is considered an anti-pattern, as the enumeration choices already imply their respective types (enum_with_type)" --- softbinding-algorithm-entry-schema.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/softbinding-algorithm-entry-schema.json b/softbinding-algorithm-entry-schema.json index deb1794..b640fa8 100644 --- a/softbinding-algorithm-entry-schema.json +++ b/softbinding-algorithm-entry-schema.json @@ -19,7 +19,6 @@ "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`)" }, "type": { - "type": "string", "enum": [ "watermark", "fingerprint" @@ -30,7 +29,6 @@ "type": "array", "minItems": 1, "items": { - "type": "string", "enum": [ "application", "audio", From 3e0528cac6aaaf0496019cde9f7504f193299ac0 Mon Sep 17 00:00:00 2001 From: Adam Goldberg Date: Thu, 24 Jul 2025 12:26:51 -0400 Subject: [PATCH 4/7] Fixing invokation syntax --- .github/workflows/validate-json.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-json.yaml b/.github/workflows/validate-json.yaml index 7b7953e..789d87a 100644 --- a/.github/workflows/validate-json.yaml +++ b/.github/workflows/validate-json.yaml @@ -28,5 +28,5 @@ jobs: run: | echo "Validating softbinding-algorithm-list.json against schema..." set -e # Exit on any error - jsonschema validate softbinding-algorithm-list.json --schema softbinding-algorithm-entry-schema.json + jsonschema validate softbinding-algorithm-entry-schema.json softbinding-algorithm-list.json echo "✓ softbinding-algorithm-list.json is valid against the schema" \ No newline at end of file From 2480f4697f9ea5f3390a618577450e3c07300385 Mon Sep 17 00:00:00 2001 From: Adam Goldberg Date: Thu, 24 Jul 2025 13:00:03 -0400 Subject: [PATCH 5/7] Modified schema to describe an array of objects, not just a single object. --- softbinding-algorithm-entry-schema.json | 202 ++++++++++++------------ 1 file changed, 104 insertions(+), 98 deletions(-) diff --git a/softbinding-algorithm-entry-schema.json b/softbinding-algorithm-entry-schema.json index b640fa8..bad396b 100644 --- a/softbinding-algorithm-entry-schema.json +++ b/softbinding-algorithm-entry-schema.json @@ -1,108 +1,114 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", - "properties": { - "identifier": { - "type": "integer", - "minimum": 0, - "maximum": 65535, - "description": "This identifier will be assigned when the soft binding algorithm is added to the list." - }, - "deprecated": { - "type": "boolean", - "default": false, - "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." - }, - "alg": { - "type": "string", - "pattern": "(c2pa\\.|[A-Za-z0-9\\-\\.]+)", - "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`)" - }, - "type": { - "enum": [ - "watermark", - "fingerprint" - ], - "description": "Type of soft binding implemented by this algorithm." - }, - "decodedMediaTypes": { - "type": "array", - "minItems": 1, - "items": { + "$id": "https://c2pa.org/schemas/softbinding-algorithm-list.json", + "type": "array", + "items": { + "type": "object", + "properties": { + "identifier": { + "type": "integer", + "minimum": 0, + "maximum": 65535, + "description": "This identifier will be assigned when the soft binding algorithm is added to the list." + }, + "deprecated": { + "type": "boolean", + "default": false, + "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." + }, + "alg": { + "type": "string", + "pattern": "(c2pa\\.|[A-Za-z0-9\\-\\.]+)", + "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`)" + }, + "type": { "enum": [ - "application", - "audio", - "image", - "model", - "text", - "video" + "watermark", + "fingerprint" ], - "description": "IANA top level media type (rendered) for which this soft binding algorithm applies." - } - }, - "encodedMediaTypes": { - "type": "array", - "minItems": 1, - "items": { - "type": "string", - "description": "IANA media type for which this soft binding algorithm applies, e.g., application/pdf", - "pattern": "^([a-zA-Z0-9\\-]+\\/[a-zA-Z0-9\\-\\+]+(?:\\.[a-zA-Z0-9\\-\\+]+)*)$" - } - }, - "entryMetadata": { - "type": "object", - "properties": { - "description": { - "type": "string", - "description": "Human readable description of the algorithm." - }, - "dateEntered": { + "description": "Type of soft binding implemented by this algorithm." + }, + "decodedMediaTypes": { + "type": "array", + "minItems": 1, + "items": { + "enum": [ + "application", + "audio", + "image", + "model", + "text", + "video" + ], + "description": "IANA top level media type (rendered) for which this soft binding algorithm applies." + } + }, + "encodedMediaTypes": { + "type": "array", + "minItems": 1, + "items": { "type": "string", - "format": "date-time", - "description": "Date of entry for this algorithm." + "description": "IANA media type for which this soft binding algorithm applies, e.g., application/pdf", + "pattern": "^([a-zA-Z0-9\\-]+\\/[a-zA-Z0-9\\-\\+]+(?:\\.[a-zA-Z0-9\\-\\+]+)*)$" + } + }, + "entryMetadata": { + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "Human readable description of the algorithm." + }, + "dateEntered": { + "type": "string", + "format": "date-time", + "description": "Date of entry for this algorithm." + }, + "contact": { + "type": "string", + "format": "email" + }, + "informationalUrl": { + "type": "string", + "format": "uri", + "description": "A web page containing more details about the algorithm." + } }, - "contact": { + "required": [ + "description", + "dateEntered", + "contact", + "informationalUrl" + ] + }, + "softBindingResolutionApis": { + "type": "array", + "items": { "type": "string", - "format": "email" + "format": "uri" }, - "informationalUrl": { - "type": "string", - "format": "uri", - "description": "A web page containing more details about the algorithm." - } - }, - "required": [ - "description", - "dateEntered", - "contact", - "informationalUrl" - ] + "description": "A list of Soft Binding Resolution APIs supporting this algorithm." + } }, - "softBindingResolutionApis": { - "type": "array", - "items": { - "type": "string", - "format": "uri" + "oneOf": [ + { + "required": ["decodedMediaTypes"], + "not": { + "required": ["encodedMediaTypes"] + } }, - "description": "A list of Soft Binding Resolution APIs supporting this algorithm." - } - }, - "required": [ - "identifier", - "alg", - "type", - "entryMetadata" - ], - "oneOf": [ - { - "required": [ - "decodedMediaTypes" - ] - }, - { - "required": [ - "encodedMediaTypes" - ] - } - ] -} + { + "required": ["encodedMediaTypes"], + "not": { + "required": ["decodedMediaTypes"] + } + } + ], + "required": [ + "identifier", + "alg", + "type", + "entryMetadata" + ] + } +} \ No newline at end of file From d8764ff9fbf1410f55ab3eb9d8e0af510b6274f4 Mon Sep 17 00:00:00 2001 From: Adam Goldberg Date: Wed, 20 Aug 2025 10:24:03 -0400 Subject: [PATCH 6/7] Update softbinding-algorithm-entry-schema.json Co-authored-by: Dominique Guinard --- softbinding-algorithm-entry-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/softbinding-algorithm-entry-schema.json b/softbinding-algorithm-entry-schema.json index bad396b..5d0587a 100644 --- a/softbinding-algorithm-entry-schema.json +++ b/softbinding-algorithm-entry-schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://c2pa.org/schemas/softbinding-algorithm-list.json", + "$id": "https://spec.c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_soft_binding_algorithm_list", "type": "array", "items": { "type": "object", From 6dd8716e47acfa5b191bc4bb2a5a864a2936af31 Mon Sep 17 00:00:00 2001 From: Adam Goldberg Date: Wed, 20 Aug 2025 11:16:21 -0400 Subject: [PATCH 7/7] Update softbinding-algorithm-entry-schema.json Co-authored-by: Dominique Guinard --- softbinding-algorithm-entry-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/softbinding-algorithm-entry-schema.json b/softbinding-algorithm-entry-schema.json index 5d0587a..12bbbc6 100644 --- a/softbinding-algorithm-entry-schema.json +++ b/softbinding-algorithm-entry-schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://spec.c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html#_soft_binding_algorithm_list", + "$id": "https://spec.c2pa.org/specifications/specifications/2.2/specs/C2PA_Specification.html", "type": "array", "items": { "type": "object",