From ea801a93b638852af7f7d2583339416a5a4a7799 Mon Sep 17 00:00:00 2001 From: Daniel Bauer Date: Tue, 12 Nov 2024 14:50:23 +0100 Subject: [PATCH] fix: RO-Crate validation should work for nested properties without id fixes issue #27 --- .../ro-crate/must/0_file_descriptor_format.py | 2 +- .../not_flattened/ro-crate-metadata.json | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/rocrate_validator/profiles/ro-crate/must/0_file_descriptor_format.py b/rocrate_validator/profiles/ro-crate/must/0_file_descriptor_format.py index c823f9e..e1e4bea 100644 --- a/rocrate_validator/profiles/ro-crate/must/0_file_descriptor_format.py +++ b/rocrate_validator/profiles/ro-crate/must/0_file_descriptor_format.py @@ -109,7 +109,7 @@ def is_entity_flat_recursive(entity: Any, is_first: bool = True) -> bool: return False # if this is not the root element, it must not contain more properties than @id else: - if "@id" in entity and len(entity) > 1: + if "@id" not in entity or len(entity) > 1: return False if isinstance(entity, list): for element in entity: diff --git a/tests/data/crates/invalid/0_file_descriptor_format/invalid_jsonld_format/not_flattened/ro-crate-metadata.json b/tests/data/crates/invalid/0_file_descriptor_format/invalid_jsonld_format/not_flattened/ro-crate-metadata.json index f78c330..91bf276 100644 --- a/tests/data/crates/invalid/0_file_descriptor_format/invalid_jsonld_format/not_flattened/ro-crate-metadata.json +++ b/tests/data/crates/invalid/0_file_descriptor_format/invalid_jsonld_format/not_flattened/ro-crate-metadata.json @@ -8,24 +8,24 @@ "@id": "https://w3id.org/ro/crate/1.1" }, "about": { - "@type": "Dataset", - "@id": "./", - "hasPart": [ - { - "@type": "File", - "@id": "test.csv", - "encodingFormat": "text/csv", - "name": "This is a test file", - "description": "This is a test dataset" - } - ], - "name": "This is a test dataset", - "description": "This is a test dataset", - "license": { - "@id": "https://creativecommons.org/licenses/by/4.0/" - }, - "datePublished": "2024-11-05" + "@id": "./" } + }, + { + "@id": "./", + "@type": "Dataset", + "name": "This is a test dataset", + "description": "This is a test dataset", + "license": { + "@id": "https://creativecommons.org/licenses/by/4.0/" + }, + "datePublished": "2024-11-05", + "hasPart": [ + { + "@type": "File", + "name": "File in a nested entity" + } + ] } ] }