Skip to content

IntoResponse and ApiOperationResponse derive macro for enum support #382

@m4tx

Description

@m4tx

ApiOperationResponse is currently implemented for many common types, such as Json, Result, etc. However, it might be useful to use an enum, indicating that one of many responses might be returned. Currently though, one has to implement both IntoResponse and ApiOperationResponse manually for such enum. An example how the enum could look like can be seen below:

enum MyResponse {
    A(Json<VariantAResponse>),
    B(Json<VariantBResponse>),
}

This sounds like a perfect candidate for creating derive macros which would just take all the types from the variants and create IntoResponse and ApiOperationResponse that would call respective methods depending on the variant matched on self.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions