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

Name variants on enum with repr #1181

Closed
RubberDuckShobe opened this issue Nov 2, 2024 · 2 comments
Closed

Name variants on enum with repr #1181

RubberDuckShobe opened this issue Nov 2, 2024 · 2 comments

Comments

@RubberDuckShobe
Copy link

Hello, I have an enum like this:

#[derive(ToSchema)]
#[repr(i16)]
pub enum AccountType {
    User,
    Moderator,
    Team,
}

In the OpenAPI spec that was generated, it only shows the integers, with no name at all:
image-67~2

Is there a way to specify the name for enum variants? It'd be great to be able to have the names in the spec as well.

@juhaku
Copy link
Owner

juhaku commented Nov 3, 2024

I would say this is a duplicate for this #954. Since enums in general are represented in JSON Schema as enum: [...] There is no way to add any description on them. https://json-schema.org/understanding-json-schema/reference/enum.

While this doc is for OpenAPI 3.0 https://swagger.io/docs/specification/v3_0/data-models/enums/ it contains an example of how to leverage a description field to further expand what the enums contains.

Also if you remove the repr(i16) you will get enum that shows the names only. But those are the options basically. Anything else would need the enum itself not being represented as an enum but a type constructed from allOf and other attributes necessary to represent type with name.

@RubberDuckShobe
Copy link
Author

Thanks for the help, I'll see. Sorry for the duplicate

@RubberDuckShobe RubberDuckShobe closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2024
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

No branches or pull requests

2 participants