Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update validation to check that file name matches id #43

Open
ibevers opened this issue May 16, 2024 · 4 comments
Open

Update validation to check that file name matches id #43

ibevers opened this issue May 16, 2024 · 4 comments
Assignees

Comments

@ibevers
Copy link

ibevers commented May 16, 2024

From @satra @djarecka :
"@id needs to match the filename"
"if validation is passing with this, please ask dorota to add that to the validator"

@djarecka djarecka self-assigned this May 16, 2024
@djarecka
Copy link
Member

should this be true for all classes or only for some specific ones, e.g. Item?

@satra
Copy link
Contributor

satra commented May 18, 2024

activity, protocol, and item are the ones that use id dereferencing on github and locally, hence those.

@Remi-Gau
Copy link
Contributor

I had this code snipper lying around on one of my repos if that helps.

import json
import os

tested = 0
for root, _, files in os.walk("schemas", topdown=True):
    for name in files:
        filename = os.path.join(root, name)
        with open(filename) as fp:
            try:
                tested += 1
                data = json.load(fp)
                if data["@id"] and data["@id"] != name:
                    raise ValueError(f"{root}/{name} does not have matching @id")
            except json.decoder.JSONDecodeError:
                print(f"{root}/{name} could not be loaded")
                raise
if tested == 0:
    raise ValueError("Zero files tested")

@yibeichan
Copy link
Contributor

@djarecka did our new reproschema model solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants