smart-data-models / data-models

Data Models in common use based on real world use-cases. These definitions underpin a digital market of interoperable and replicable smart solutions.
https://smartdatamodels.org/
114 stars 56 forks source link

Make the schemas usable in a validator #64

Closed EliottPaillard closed 1 month ago

EliottPaillard commented 3 months ago

It seems like "http://json-schema.org/schema#" is deprecated and prevent the associated schema to be used in a JSON validator. As "https://json-schema.org/draft/2020-12/schema" corresponds to the up-to-date version, I propose to change the line like this. Also It should be modify in every schema of smart data models

albertoabellagarcia commented 2 months ago

First of all sorry for the delayed answer (holidays).

I see the result of both links pointing to the same place. Could you provide us with more info? if it is too long to explain in a message you can book a session with us in this link

EliottPaillard commented 2 months ago

Hey! Sorry, the quote between "" was not intended to be a hyperlink. So the point is not about the files they point to.

You can see in the "commits" part what are the changes I propose. For now, the "$schema" value of all your schemas is "http://json-schema.org/schema#" (again, the string itself is important, not the linked file). This value prevent the schema to be used in any JSON validator.

You can test it by yourself with this validator: https://www.itb.ec.europa.eu/json/any/upload You can set the content to validate to " {} " for example. Then as the JSON schema put : " { "$schema": "http://json-schema.org/schema#", "$id": "https://smart-data-models.github.io/data-models/Entity-ngsiv2-datamodels-schema.json", "title": "NGSIv2 Entity. Normalized Format for Smart Data Models" } " You will see an error appears. And I can tell you that it's not this validator fault. But just by replacing the mentioned value by a non-deprecated one (for now the last available is "https://json-schema.org/draft/2020-12/schema"), you will be able to use the schema.

Now most of the smart-data-models schemas call other schemas in them. You can try, but if you take basically any of them, and I you don't modify also the called schemas, you will still not be able to use it. So in fact to make your schemas usable in a validator, you would need to make this replacement in all of them.

albertoabellagarcia commented 2 months ago

What we can really do, is to change http by https with this it should work. Your changes would make us to change all schemas once there is a new version of the meta-schema of json schema. We will implement this soon so possibly it would fix what you need.

EliottPaillard commented 2 months ago

Do you mean change "http://json-schema.org/schema#" by "https://json-schema.org/schema#"?

Because that doesn't work either.

EliottPaillard commented 2 months ago

These changes can be made with a python script, and this script will be useful to update the version again later if it's needed.

albertoabellagarcia commented 1 month ago

I think that this validator is simply wrong, these ones validate perfectly this schemas https://www.jsonschemavalidator.net/ https://jsonschema.dev/ It is true that these ones also report this error https://jsonschemalint.com/#!/version/draft-07/markup/json https://json-schema.hyperjump.io/

I am going to report it to the json schema community because, but for the https, it should work, I am not clear why a redirection is not allowed there

albertoabellagarcia commented 1 month ago

Running the script to update to the last version https://json-schema.org/draft/2020-12/schema

Initially today all data models will be updated

Thanks and sorry for the delay