| Crates.io | sensorthings-validator |
| lib.rs | sensorthings-validator |
| version | 0.4.1 |
| created_at | 2025-11-16 04:38:18.433446+00 |
| updated_at | 2026-01-10 05:58:12.441993+00 |
| description | A Rust CLI tool that validates SensorThings API endpoints and responses. |
| homepage | |
| repository | https://codeberg.org/Cooperatief-Meten-Natuurlijk-UA/sensorthings-validator |
| max_upload_size | |
| id | 1935180 |
| size | 1,001,993 |
This project is a Rust-based validator for the OGC SensorThings API.
Its purpose is to automatically check endpoints of a SensorThings server for required and optional fields, validate write operations, and provide both human‑readable console summaries and machine‑readable JSON output.
validation_result.json including arrays of missing required/optional fields.src/
├── app.rs // Application orchestration
├── cli.rs // CLI argument definitions
├── config.rs // Configuration and settings
├── endpoints.rs // GET validation fields
├── error.rs // Custom error type and handling
├── lib.rs // Library entrypoint
├── main.rs // CLI entrypoint
├── output_console.rs // Console summary output
├── output_json.rs // JSON export output
├── read_validator.rs // Read checks (GET validation)
├── result.rs // Result struct and helpers
├── write_validator.rs // Write checks (POST/GET roundtrip)
└── writer_payloads.rs // Minimal payloads per entity
git clone https://codeberg.org/Cooperatief-Meten-Natuurlijk-UA/sensorthings-validator.git
cd sensorthings-validator
cargo build --release
Run the validator against a SensorThings service:
sensorthings-validator --host api.example.com --port 80
Usage: sensorthings-validator [OPTIONS]
Options:
--protocol <PROTOCOL> Protocol of the SensorThings API [default: http]
[possible values: http, https]
--host <HOST> Host of the SensorThings API [default: localhost]
--port <PORT> Port of the SensorThings API [default: 8080]
--prefix <PREFIX> Optional URL path prefix [default: ""]
--check-optional Check optional fields as well as required ones
--check-sta-plus Enable STAplus validation (extra endpoints and fields)
--check-write Enable write validation (POST/GET roundtrip checks)
-h, --help Print help
-V, --version Print version
The protocol, host, port, and optional prefix are combined into a base URL of the form:
<protocol>://<host>:<port>/<prefix>
# Validate against a local instance
sensorthings-validator --host localhost --port 8080
# Validate against a remote server and include optional fields
sensorthings-validator --host api.example.com --port 80 --check-optional
# Validate STAplus extensions
sensorthings-validator --host api.example.com --port 80 --check-sta-plus
# Validate write operations (POST/GET roundtrip)
sensorthings-validator --host api.example.com --port 80 --check-write
# Validate with a custom prefix
sensorthings-validator --host api.example.com --port 443 --prefix api/v1
# Validate using HTTPS
sensorthings-validator --protocol https --host secure.example.com --port 443 --prefix api/v2
Read Validation Summary:
Entity Path Body Path Msg Body Msg
Things ✅ ✅ HTTP 200 OK All required fields present
Observations ✅ ❌ HTTP 200 OK Missing required fields [author, campaign]
validation_result.json){
"base_url": "http://localhost:3000",
"read": {
"check_type": "Read",
"results": [
{
"name": "Observations",
"path_ok": true,
"body_ok": false,
"path_msg": "HTTP 200 OK",
"body_msg": "Missing required fields",
"missing_required": ["author", "campaign"],
"missing_optional": []
}
]
},
"write": null
}
Run the test suite with:
cargo test
SPDX-License-Identifier: MIT
Copyright (c) 2025 Egon Kastelijn