Skip to content
Snippets Groups Projects
Commit 558d0d1e authored by Dmitrii Valuiskii (EPAM)'s avatar Dmitrii Valuiskii (EPAM) Committed by Siarhei Khaletski (EPAM)
Browse files

GONRG-1721: fix pre-defined ids validation error

parent cca0b300
No related branches found
No related tags found
1 merge request!11Fix for pre-defined Ids and autogenerated Ids
...@@ -39,8 +39,10 @@ class ManifestTraversal(object): ...@@ -39,8 +39,10 @@ class ManifestTraversal(object):
:param schema: corresponding generic schema (for future schema validation) :param schema: corresponding generic schema (for future schema validation)
:return: :return:
""" """
extracted_schema = schema.split("/")[-1]
logger.debug(f"Extracted schema kind: {extracted_schema}")
return { return {
"schema": schema, "schema": extracted_schema,
"entity": entity "entity": entity
} }
......
...@@ -158,18 +158,12 @@ class SchemaValidator(HeadersMixin): ...@@ -158,18 +158,12 @@ class SchemaValidator(HeadersMixin):
raise e raise e
return response return response
def _delete_id_pattern(self, schema: dict) -> dict:
if schema.get("properties") and schema["properties"].get("id"):
schema["properties"]["id"].pop("pattern", None)
return schema
def _validate_entity(self, entity: dict, schema: dict = None): def _validate_entity(self, entity: dict, schema: dict = None):
""" """
Validate the 'data' field of any entity against a schema got by entity's kind. Validate the 'data' field of any entity against a schema got by entity's kind.
""" """
if not schema: if not schema:
schema = self.get_schema(entity["kind"]) schema = self.get_schema(entity["kind"])
schema = self._delete_id_pattern(schema)
data = entity["data"] data = entity["data"]
try: try:
self._validate_against_schema(schema, data) self._validate_against_schema(schema, data)
...@@ -258,7 +252,7 @@ class SchemaValidator(HeadersMixin): ...@@ -258,7 +252,7 @@ class SchemaValidator(HeadersMixin):
return True return True
except exceptions.ValidationError as exc: except exceptions.ValidationError as exc:
logger.error("Schema validation error.") logger.error("Schema validation error.")
logger.error(f"Manifest kind: {schema['kind']}") logger.error(f"Manifest kind: {entity['kind']}")
logger.error(f"Manifest: {entity}") logger.error(f"Manifest: {entity}")
logger.error(f"Error: {exc}") logger.error(f"Error: {exc}")
return False return False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment