kurtbuilds / oasgen

Generates OpenAPI 3.0 spec based on Rust code. Works with axum, actix-web, or any/no framework.
https://crates.io/crates/oasgen
112 stars 8 forks source link

Support for complex enums using OaSchema derive macro #8

Closed thorjelly closed 12 months ago

thorjelly commented 1 year ago

Allows the OaSchema derive macro to work with complex enums, AKA tagged unions, by using the openapi oneOf keyword. This supports all serde tag types; external, internal, adjacent, and untagged. This should support variants of all kinds, including newtype variants, struct variants, tuple variants, and unit variants.

Depends on PR #7

kurtbuilds commented 12 months ago

I had to make a few modifications with recent library changes, but all the tests are passing.

One note, is there's now an #[oasgen(inline)] configuration, which specifies whether the schema will be a $ref or will be inlined. I expanded the complex enum test to have inline and non-inline variants for all enum types (external, adjacent, internal, untagged).