-
-
Notifications
You must be signed in to change notification settings - Fork 295
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
Error in openapi schema for Enum #121
Comments
I have validated this specification on https://editor.swagger.io/
|
How to handle the renaming of a field in a poem ? |
Thank you very much, fixed in https://docs.rs/poem-openapi/1.0.40/poem_openapi/derive.Enum.html#item-parameters #[derive(Enum)]
enum MyEnum {
CreateUser,
#[oai(rename = "delete_user")]
DeleteUser,
} |
Works beautifully :) And are there any equivalents for these attributes ? |
I think it will be good for my API if I get rid of these two attributes untagged and deny_unknown_fields. |
I want to deny unknown fields by default, what do you think? @szagi3891 |
Yes, it would be nice to have this option. Would it be possible to make an equivalent for this switch ? |
Sorry, can you tell me what |
https://serde.rs/enum-representations.html#untagged Then you can have many different variants of objects with different types. Something like OneOf but without the field that defines their type. |
How to define this type in the spec? |
I guess you want this? #[serde(tag = "type")]
enum Obj {
A {
a: i32,
}
B {
b: i32
}
} |
This is a sample schema:
In this case of use, the field that specifies the type of variant of the enum is not used at all |
This schema above, is generated from such a rustic structure|:
|
Released in |
Expected Behavior
A different type is expected for the enum:
Actual Behavior
Steps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: