Expand description
This crate provides global configuration capabilities for fastapi
.
§Config options
- Define rust type aliases for
fastapi
with.alias_for(...)
method. - Define schema collect mode for
fastapi
with.schema_collect(...)
method.SchemaCollect::All
will collect all schemas from usages including inlined withinline(T)
SchemaCollect::NonInlined
will only collect non inlined schemas from usages.
Warning!
The build config will be stored to projects OUTPUT
directory. It is then read from there via OUTPUT
environment
variable which will return any instance rust compiler might find at that time (Whatever the OUTPUT
environment variable points to).
Be aware that sometimes you might face a situation where the config is not aligned with your Rust aliases.
This might need you to change something on your code before changed config might apply.
§Install
Add dependency declaration to Cargo.toml
.
[build-dependencies]
fastapi-config = "0.1"
§Examples
Create build.rs
file with following content, then in your code you can just use MyType
as
alternative for i32
.
use fastapi_config::Config;
fn main() {
Config::new()
.alias_for("MyType", "i32")
.write_to_file();
}
See full example for fastapi-config.
Structs§
- Config
- Global configuration initialized in
build.rs
of user project.
Enums§
- Schema
Collect - Configures schema collect mode. By default only non explicitly inlined schemas are collected.
but this behavior can be changed to collect also inlined schemas by setting
SchemaCollect::All
.