Crate poem_openapi_problemdetails

Crate poem_openapi_problemdetails 

Source
Expand description

§poem-openapi-problemdetails-macro

This crate provides an integration layer between the problemdetails and poem_openapi.

§Usage

To use the provided macro, first implement [std::error::StdError] for you like. Use the ApiProblemDetails macro.

#[derive(Debug, thiserror::Error, poem_openapi_problemdetails::ApiProblemDetails)]
enum EndpointError {
    #[error("An invalid value was provided")]
    #[oai_problemdetails(
        status = 422,
        title = "An invalid value was provided",
        ty = "https://example.net/validation-error"
    )]
    InvalidValue
}

Doing so adds the response to the generated openapi specification.

§Fields

The following fields can be provided at this moment

NameField nameRequiredDescription
statusstatustrueThe HTTP status code generated by the origin server for this occurrence of the problem
titletitlefalseA short, human-readable summary of the problem type
tytypefalseA URI reference [RFC3986] that identifies the problem type.
detaildetailfalseA human-readable explanation specific to this occurrence of the problem.

Re-exports§

pub use poem;
pub use poem_openapi;
pub use problemdetails;
pub use serde_json;

Derive Macros§

ApiProblemDetails
Macro to generate problemdetails responses based on the provided macro input. See the root libary for documentation.