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

[REQ] Better enum support in rust #10977

Open
John-Toohey opened this issue Nov 27, 2021 · 0 comments
Open

[REQ] Better enum support in rust #10977

John-Toohey opened this issue Nov 27, 2021 · 0 comments

Comments

@John-Toohey
Copy link

Is your feature request related to a problem? Please describe.

Whilst I quite like this project, i found a problem arises with the rust enums. This arises when you have error enums which have no fields, such as in the pet store example:

responses:
  400:
    description: Invalid ID supplied
  404:
    description: Pet not found
  405:
    description: Validation exception

With the error codes 400, 404 and 405 since they have no content they will fail to convert into the enumerated response generated and so instead will have to be accessed via a response error.

Describe the solution you'd like

Rather than using #[serde(untagged)] I think it might be better to work based of status code. It might also be good to implement Display and Error on the error type using the description field.

Describe alternatives you've considered

So far in my project I have just been using the ResponseError sub variant instead, but this is clunky. Another option would be to separate the functionality mentioned above into an additional feature.

In addition a trait could be made such as DesieralizeWithStatusCode to ease the project.

Anyhow, many thanks with this project, it is so much easier than manually creating a reqwest library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant