Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing enum variant examples #538

Merged
merged 2 commits into from
Mar 22, 2023
Merged

Conversation

juhaku
Copy link
Owner

@juhaku juhaku commented Mar 22, 2023

Add missing example support for enum variants. According to the docs enum variants should have support for example attribute: https://docs.rs/utoipa/latest/utoipa/derive.ToSchema.html#enum-variant-optional-configuration-options-for-schema.

This commit implements the tokenization support for example attribute at complex enum.

let value: Value = api_doc! {
    enum EnumWithExample {
        #[schema(example = "EX: Unit")]
        UnitValue,
        #[schema(example = "EX: Named")]
        NamedFields {
            #[schema(example = "EX: Named id field")]
            id: &'static str,
        },
        #[schema(example = "EX: Unnamed")]
        UnnamedFields(Foo),
    }
};

Relates #470

@juhaku juhaku merged commit b2e99a8 into master Mar 22, 2023
@juhaku juhaku deleted the add-missing-enum-variant-examples branch March 22, 2023 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

1 participant