pub trait Content {
const MEDIA_TYPE: &'static str;
const REQUIRED: bool = true;
// Required method
fn schema(generator: &mut SchemaGenerator) -> Schema;
}Available on crate feature
openapi only.Expand description
A request or response body that an API document can describe.
A type names its media type and the schema of its payload. Pass such a
type to Operation::request or
Operation::response_with.
Implement it for your own extractors and response types:
use topcoat::openapi::{
Content,
schemars::{Schema, SchemaGenerator, json_schema},
};
struct Csv(String);
impl Content for Csv {
const MEDIA_TYPE: &'static str = "text/csv";
fn schema(_generator: &mut SchemaGenerator) -> Schema {
json_schema!({ "type": "string" })
}
}Required Associated Constants§
Sourceconst MEDIA_TYPE: &'static str
const MEDIA_TYPE: &'static str
The media type of the body, such as application/json.
Provided Associated Constants§
Required Methods§
Sourcefn schema(generator: &mut SchemaGenerator) -> Schema
fn schema(generator: &mut SchemaGenerator) -> Schema
Returns the schema of the payload.
Call SchemaGenerator::subschema_for for a payload type that
implements JsonSchema, so the document lists the type once and
refers to it from every body that uses it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".