labthings_fastapi.thing_description.validation

Validate a generated Thing Description against the W3C schema.

We generate Thing Description using pydantic models so there is a layer of validation applied every time one is created. However, this module allows the generated JSON document to be formally validated against the schema in the W3C specification, as an additional check.

See Thing Description for a link to the specification in human-readable format.

Functions

validate_thing_description(→ None)

Validate a Thing Description.

Module Contents

labthings_fastapi.thing_description.validation.validate_thing_description(td: dict) None

Validate a Thing Description.

This accepts a dictionary (usually generated from labthings_fastapi.thing_description._model.ThingDescription.model_dump() ) and validates it against the JSON schema for Thing Descriptions. This is obtained from the W3C’s Thing Description repository on GitHub, URL in the file.

No return value is provided, but a ValidationError is raised if the schema is invalid.

Parameters:

td – the Thing Description to be validated.

Raises:

jsonschema.exceptions.ValidationError – if the Thing Description is invalid.