From 666041c9c94aa94bcb0f43460b5af957799b39a9 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 25 Feb 2020 14:54:59 +0100 Subject: [PATCH] added schema validation and fixed master version schema --- .../plugins/global/publish/integrate_master_version.py | 7 +++++-- schema/master_version-1.0.json | 10 ++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pype/plugins/global/publish/integrate_master_version.py b/pype/plugins/global/publish/integrate_master_version.py index 2a23abfbec..715d99c1c8 100644 --- a/pype/plugins/global/publish/integrate_master_version.py +++ b/pype/plugins/global/publish/integrate_master_version.py @@ -6,7 +6,7 @@ import shutil from pymongo import InsertOne, ReplaceOne import pyblish.api -from avalon import api, io, pipeline +from avalon import api, io, schema from avalon.vendor import filelink @@ -162,6 +162,7 @@ class IntegrateMasterVersion(pyblish.api.InstancePlugin): "type": "master_version", "schema": "pype:master_version-1.0" } + schema.validate(new_master_version) # Don't make changes in database until everything is O.K. bulk_writes = [] @@ -286,9 +287,11 @@ class IntegrateMasterVersion(pyblish.api.InstancePlugin): repre["parent"] = new_master_version["_id"] repre["context"] = repre_context repre["data"] = repre_data + repre.pop("_id", None) + + schema.validate(repre) repre_name_low = repre["name"].lower() - # Replace current representation if repre_name_low in old_repres_to_replace: old_repre = old_repres_to_replace.pop(repre_name_low) diff --git a/schema/master_version-1.0.json b/schema/master_version-1.0.json index 173a076537..991594648b 100644 --- a/schema/master_version-1.0.json +++ b/schema/master_version-1.0.json @@ -17,14 +17,13 @@ "properties": { "_id": { "description": "Document's id (database will create it's if not entered)", - "type": "ObjectId", - "example": "592c33475f8c1b064c4d1696" + "example": "ObjectId(592c33475f8c1b064c4d1696)" }, "schema": { "description": "The schema associated with this document", "type": "string", - "enum": ["avalon-core:master_version-3.0", "pype:master_version-3.0"], - "example": "pype:master_version-3.0" + "enum": ["avalon-core:master_version-1.0", "pype:master_version-1.0"], + "example": "pype:master_version-1.0" }, "type": { "description": "The type of document", @@ -34,8 +33,7 @@ }, "parent": { "description": "Unique identifier to parent document", - "type": "ObjectId", - "example": "592c33475f8c1b064c4d1696" + "example": "ObjectId(592c33475f8c1b064c4d1697)" } } }