#[non_exhaustive]pub struct Config<'c> {
pub schema_collect: SchemaCollect,
/* private fields */
}
Expand description
Global configuration initialized in build.rs
of user project.
This works similar fashion to what hyperium/tonic
grpc library does with the project configuration. See
the quick usage from module documentation
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.schema_collect: SchemaCollect
Schema collect mode for utoipa
. By default only non inlined schemas are collected.
Implementations§
source§impl<'c> Config<'c>
impl<'c> Config<'c>
sourcepub fn alias_for(self, alias: &'c str, value: &'c str) -> Config<'c>
pub fn alias_for(self, alias: &'c str, value: &'c str) -> Config<'c>
Add new global alias.
This method accepts two arguments. First being identifier of the user’s type alias.
Second is the type path definition to be used as alias value. The value
can be anything
that utoipa
can parse as TypeTree
and can be used as type for a value.
Because of TypeTree
the aliased value can also be a fairly complex type and not limited
to primitive types. This also allows users create custom types which can be treated as
primitive types. E.g. One could create custom date time type that is treated as chrono’s
DateTime or a String.
§Examples
Create MyType
alias for i32
.
use utoipa_config::Config;
let _ = Config::new()
.alias_for("MyType", "i32");
Create Json
alias for serde_json::Value
.
use utoipa_config::Config;
let _ = Config::new()
.alias_for("Json", "Value");
Create NullableString
alias for Option<String>
.
use utoipa_config::Config;
let _ = Config::new()
.alias_for("NullableString", "Option<String>");
sourcepub fn schema_collect(self, schema_collect: SchemaCollect) -> Self
pub fn schema_collect(self, schema_collect: SchemaCollect) -> Self
Define schema collect mode for utoipa
.
Method accepts one argument SchemaCollect
which defines the collect mode to be used by
utiopa
. If none is defined SchemaCollect::NonInlined
schemas will be collected by
default.
This can be changed to SchemaCollect::All
if schemas called with inline(T)
is wished
to be collected to the resulting OpenAPI.