From 61525d7c755dcace7e5fd584a8ecf836438c732e Mon Sep 17 00:00:00 2001
From: Mattia Basaglia <glax@dragon.best>
Date: Tue, 17 Sep 2024 17:53:34 +0200
Subject: [PATCH] Schema 1.0 (#96)

* Bump specs version to 1.0

* Too many 00

* Allow version numbers without patch
---
 schema/composition/animation.json |  2 +-
 schema/root.json                  |  4 ++--
 tools/schema-validate.py          | 18 +++++++++++-------
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/schema/composition/animation.json b/schema/composition/animation.json
index 58e8e83..b6df275 100644
--- a/schema/composition/animation.json
+++ b/schema/composition/animation.json
@@ -14,7 +14,7 @@
                     "title": "Specification Version",
                     "description": "Specification version this Lottie is targeting. This is a 6 digit number with version components encoded as `MMmmpp`, with `MM` being major version, `mm` being minor and `pp` being patch.",
                     "type": "integer",
-                    "minimum": 100
+                    "minimum": 10000
                 },
                 "fr": {
                     "title": "Framerate",
diff --git a/schema/root.json b/schema/root.json
index 01cf915..549dc29 100644
--- a/schema/root.json
+++ b/schema/root.json
@@ -1,6 +1,6 @@
 {
     "$schema": "https://json-schema.org/draft/2020-12/schema",
-    "$id": "https://lottie.github.io/lottie-spec/specs/schema/0.1.0",
+    "$id": "https://lottie.github.io/lottie-spec/1.0/specs/schema/",
     "$ref": "#/$defs/composition/animation",
-    "$version": 100
+    "$version": 10000
 }
diff --git a/tools/schema-validate.py b/tools/schema-validate.py
index 7e749da..d5f8f5b 100755
--- a/tools/schema-validate.py
+++ b/tools/schema-validate.py
@@ -70,16 +70,20 @@ def collect_defs(self, schema):
                 self.collect_defs(child)
 
     def check_version(self, schema: Schema):
-        versionNumber = schema["$version"]
+        version_number = schema["$version"]
 
-        majorVersion = versionNumber // 10000
-        minorVersion = (versionNumber % 10000) // 100
-        patchVersion = versionNumber % 100
+        major_version = version_number // 10000
+        minor_version = (version_number % 10000) // 100
+        patch_version = version_number % 100
 
-        versionString = f'{majorVersion}.{minorVersion}.{patchVersion}'
+        components = [major_version, minor_version]
+        if patch_version != 0:
+            components.append(patch_version)
 
-        if versionString not in schema["$id"]:
-            self.error(schema, "Mismatched URI version - expected: %s" % versionString)
+        version_string = ".".join(map(str, components))
+
+        if version_string not in schema["$id"]:
+            self.error(schema, "Mismatched URI version - expected: %s" % version_string)
 
     def check_links(self, html_path: pathlib.Path):
         checked = set()