juhaku / utoipa

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

[FEATURE REQUEST] Deeply / recursively export components into openapi #1025

Open clotodex opened 2 weeks ago

clotodex commented 2 weeks ago

(I am using axum and the axum bindings) I noticed that to completely export a type I also have to list all subtypes in the components. While this offers 100% felxibility, I am trying to export generated code which means I need to import and list every single subtype manually, which is errorprone.

Example:

struct Rectangle { width: f64, height: f64, }

struct Triangle { base: f64, height: f64, }

// Define the enum that wraps the different shape structs enum Shape { Circle(Circle), Rectangle(Rectangle), Triangle(Triangle), }



Then I cannot just list `Shape` in the components but have to list `Shape, Rectangle, Triangle, Circle` ...

Is this feasible? I used schemars with okapi before where they somehow made this work
juhaku commented 2 weeks ago

At the moment they need to be listed manually. But I'm planning to improve this eventually to the 5.0.0 version.

jayvdb commented 1 week ago

I believe this is a dup of https://github.com/juhaku/utoipa/issues/465

juhaku commented 1 week ago

Yeah it actually touches the same topic.