-
Notifications
You must be signed in to change notification settings - Fork 192
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
Support for repr attribute #282
Conversation
Also, I haven't checked how schema attributes affect macro generation. |
This is a pretty good start 💪 but support for serde attributes would be beneficial, but the rename of enum at container level is no prio since throughout the lib there is no such support and implementing it needs more planning. And tests would be be useful. There are plenty in |
I think the |
I noticed one thing. Even if the enum type is marked as
Which is incorrect:
I've already changed |
Keep in mind that the OpenAPI specification does not allow integer type of enums. https://swagger.io/specification/ If you browse to the spec and search for |
Didn't know that. Then all that's left is to write the tests. |
I think that's all for now. |
Sorry, I eat my words, I tested it in editor.swagger.io and seems like the enum can also be represented according the type of the field. e.g. components:
schemas:
Order:
type: object
properties:
status:
type: integer
description: Order Status
enum:
- 0
- 1
- 2 |
Actually to have it support dynamic enum values there is a need to change the pub struct Object {
// ...
#[serde(rename = "enum", skip_serializing_if = "Option::is_none")]
pub enum_values: Option<Vec<String>>, The string needs to be changed to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is okay there are 2 things still address here 🙂
- Add this
repr
create support behind arepr
feature flag, so people can enable it when they want. - Add docs about this new functionality to
utoipa-gen/src/lib.rs
and list the new feature also inREADME.md
and inutoipa/src/lib.rs
You can generate the doc with, and then use browser to see the output.
cargo doc --workspace --no-deps --features utoipa/json,utoipa/actix_extras,utoipa/openapi_extensions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏆 pretty good, let's get it merged
I tried to write a simple impl support of repr attribute. Right now there is no support for serde tags.
If we have something like this:
Macro generates the following output:
*.json
fileRelated to: #271