juhaku / utoipa

Simple, Fast, Code first and Compile time generated OpenAPI documentation for Rust
Apache License 2.0
2.01k stars 160 forks source link

[Feature Request] Custom Args and More #884

Open i007c opened 3 months ago

i007c commented 3 months ago

this is a very nice crate. however it lacks some feature such as adding custom variables to the schema and using them to add or remove items from the schema during the modify step. for example i put all of the user api in a file like api/user.rs. and every path in this file will be under the /user path. so its kind of wired to add context_url for all the paths. its way nicer to just use a modifier.

im currently using the first servers values as my context url

#[derive(OpenApi)]
#[openapi(
    tags((name = "api::user")),
    paths(login, user_get), 
    components(schemas(User)),
    servers((url = "/user")),
    modifiers(&UpdatePaths)
)]
pub struct ApiUserDoc;

and i also add the ApiUserDoc tags to all the paths under it.

some custom arguments would be very use full for automaticly adding or removing thigs from each path or the hole schmea