Skip to main content

velesdb_server/
types.rs

1//! Request/Response types for VelesDB REST API.
2//!
3//! Canonical DTOs are defined in `velesdb_core::api_types` and re-exported here.
4//! Server-specific types that are not shared with other crates remain in this file.
5
6// Re-export all canonical DTOs from core's api_types module.
7// The `openapi` feature is enabled in this crate, providing ToSchema derives.
8pub use velesdb_core::api_types::*;
9
10/// The plain-text `422` axum answers for a request body it cannot deserialise.
11///
12/// The `Json<T>` extractor rejects a malformed body **before the handler
13/// runs**, so the payload is a bare string, not an [`ErrorResponse`] — a
14/// client that parses every error as JSON fails twice, once on the request
15/// and once on the error.
16///
17/// Declared once and referenced by every operation that takes a JSON body.
18/// #2276 wrote it inline on three of them and #2291 measured the other
19/// twenty-one; one `components/responses` entry is what keeps a generated
20/// client with a single type for it instead of twenty-four inline copies.
21#[derive(utoipa::ToResponse)]
22#[response(
23    description = "A body the server cannot deserialise: a field of the wrong type, or JSON that does not match the request schema.",
24    content_type = "text/plain"
25)]
26pub struct MalformedBody(#[allow(dead_code)] String);