Skip to content

Add #[schema(title_variants)] attribute for mixed enums#1511

Open
leovalais wants to merge 1 commit into
juhaku:masterfrom
osrd-project:enum-variant-titles
Open

Add #[schema(title_variants)] attribute for mixed enums#1511
leovalais wants to merge 1 commit into
juhaku:masterfrom
osrd-project:enum-variant-titles

Conversation

@leovalais

Copy link
Copy Markdown

closes #865

Hi and thanks for utoipa!

Adds an enum-level attribute to generate the title of its variants. By default it is the concatenation of the enum's and the variant's name. If the enum has an explicit title set, it is used as prefix instead. All variant titles can be overridden using the field-level title attribute.

Like the issue author I've encountered some issues with code generators on rich enums. I tried to keep the new feature as simple as possible but let me know if there's missing functionality.

I'm also not sure how (or even if) it should relate to serde attributes.

@leovalais leovalais marked this pull request as ready for review January 8, 2026 17:30
@leovalais leovalais force-pushed the enum-variant-titles branch from 207c68f to 5103a24 Compare April 14, 2026 19:41
Adds an enum-level attribute to generate the `title` of its variants. By
default it is the concatenation of the enum's and the variant's name. If
the enum has an explicit `title` set, it is used as prefix instead. All
variant titles can be overridden using the field-level `title`
attribute.
@leovalais leovalais force-pushed the enum-variant-titles branch from 5103a24 to 5f5e910 Compare May 28, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Automatically derive "title" for Enum Variants

1 participant