pub trait DocumentableDTO:
Send
+ Sync
+ Debug
+ DeserializeOwned
+ Serialize
+ JsonSchema
+ Clone {
// Required method
fn get_example() -> Self;
// Provided method
fn make_example() -> Result<Value, Error> { ... }
}Expand description
A request or response type that can describe itself for documentation.
Requires JsonSchema so a schema can be derived, plus Serialize,
DeserializeOwned, Clone, and Debug. Implementors provide
get_example; make_example
serializes that example to JSON.
ⓘ
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
struct CreateUser { name: String }
impl DocumentableDTO for CreateUser {
fn get_example() -> Self {
Self { name: "ada".to_string() }
}
}Required Methods§
Sourcefn get_example() -> Self
fn get_example() -> Self
Returns a representative instance used as the documented example.
Provided Methods§
Sourcefn make_example() -> Result<Value, Error>
fn make_example() -> Result<Value, Error>
Serializes get_example to a JSON value.
Returns the serde_json error if the example cannot be serialized.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".