ProbablyClem / utoipauto

Rust Macros to automate the addition of Paths/Schemas to Utoipa crate, simulating Reflection during the compilation phase
Apache License 2.0
89 stars 9 forks source link

Customize reported path #26

Open jssblck opened 2 months ago

jssblck commented 2 months ago

Hey, awesome library! In #2, a user asked to have full paths reported; but I want the opposite: I want to be able to customize the path so that the full thing isn't reported.

For example, if I add paths manually, this works- but I don't see a way to both auto-discover and not have the full path displayed.

In the below example (using Scalar to render the docs), the main ApiDoc is configured like so:

// Note: the below code snippet is inside `crate::api`.

#[utoipauto] // <-- This autodiscovers `crate::api::v1::ping`
#[derive(OpenApi)]
#[openapi(info(description = include_str!("../README.md")), paths(
    v0::health::handle, // <-- This is also autodiscovered, but overridden
))]
struct ApiDoc;

The manually added route correctly (for my preferences anyway) appears relative, but the autodiscovered one has the full path; I'm wondering if there's a way to override this behavior to make the path relative.

Screenshot 2024-05-16 at 4 41 58 PM

Thanks for your time!

DenuxPlays commented 1 month ago

Maybe not your solution but I ordered my routes into tags. This also allows you to add a basic description.

Works for me but maybe not for you.