I'm developing a Thing Description Directory in Python (Web of Things) and i need to validate the Thing Descriptions that register to the directory, they are JSON-LD documents and i have to check if they respect the schema (https://www.w3.org/2022/wot/td/v1.1).
I'm trying to use the validate function in jsonschema library but it seems to validate correctly the Thing Descriptions that shouldn't be right according to the schema. I'm suspecting that it can't do that correctly because in the schema context there are other schemas that need to be used in order to validate the json-ld (and so on in these schemas). Is there a way to validate the json-ld considering the nested schemas? It also can't check correctly the boolean values in the json-ld, but i think that's because of the conversion to python object done by json.loads().
To correctly check if the Thing Description is valid according to the schema i use this website https://eclipse.github.io/editdor/.
Here is the piece of code i use to get the schema and validate the json-ld
Your code logic is correct but you are mixing two types of validation.
If you are doing JSON Schema based validation, you should first use a JSON Schema. The official JSON Schema for TDs is available at https://raw.githubusercontent.com/w3c/wot-thing-description/main/validation/td-json-schema-validation.json so you should fetch that instead of the JSON-LD context.
If you are trying to do semantic validation, you should use the SHACL shapes available at https://github.com/w3c/wot-thing-description/blob/main/validation/td-validation.ttl and then pick a SHACL library like https://github.com/RDFLib/pySHACL