4 releases

0.1.2 Oct 23, 2024
0.1.1 Oct 16, 2024
0.1.0 Oct 14, 2024
0.1.0-rc.0 Oct 2, 2024

#1978 in Web programming

Download history 133/week @ 2024-09-29 24/week @ 2024-10-06 356/week @ 2024-10-13 143/week @ 2024-10-20 43/week @ 2024-10-27 22/week @ 2024-11-03 13/week @ 2024-11-10 52/week @ 2024-11-17 87/week @ 2024-11-24 54/week @ 2024-12-01

207 downloads per month
Used in 2 crates (via utoipa-gen)

MIT/Apache

14KB
101 lines

utoipa-config

Utoipa build crates.io docs.rs rustc

This crate provides global configuration capabilities for utoipa.

Config options

  • Define rust type aliases for utoipa with .alias_for(...) method.
  • Define schema collect mode for utoipa with .schema_collect(...) method.
    • SchemaCollect:All will collect all schemas from usages including inlined with inline(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]
utoipa-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 utoipa_config::Config;

fn main() {
    Config::new()
        .alias_for("MyType", "i32")
        .write_to_file();
}

See full example for utoipa-config.

License

Licensed under either of Apache 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, shall be dual licensed, without any additional terms or conditions.

Dependencies

~0.7–1.6MB
~33K SLoC