poem-web / poem

A full-featured and easy-to-use web framework with the Rust programming language.
Apache License 2.0
3.62k stars 295 forks source link

Multiple 200 OK options? #810

Open iconofsin opened 6 months ago

iconofsin commented 6 months ago

What would be the way to provide for multiple 200 OK response options (different data types) and have the structs be documented in the UI as well?

Putting multiple #[oai(status = 200)] items into a single ApiResponse struct results in only the last option being reflected as the OK response for all API methods, and also apparently violates the OpenAPI spec (even though Poem still happily generates it.)

Using an Enum seems and a single #[oai(status = 200)] item seems to be more correct OpenAPI-spec wise, but the UI still only shows the last option.

Any pointers/examples? Would using distinct ApiResponse enums be the only way to achieve this?