poem_openapi_problemdetails/
lib.rs

1//! # `poem-openapi-problemdetails-macro`
2//!
3//! This crate provides an integration layer between the [`problemdetails`] and [`poem_openapi`].
4//!
5//! # Usage
6//!
7//! To use the provided macro, first implement [`std::error::StdError`] for you like. Use the
8//! [`ApiProblemDetails`] macro.
9//!
10//! ```rust
11//! #[derive(Debug, thiserror::Error, poem_openapi_problemdetails::ApiProblemDetails)]
12//! enum EndpointError {
13//!     #[error("An invalid value was provided")]
14//!     #[oai_problemdetails(
15//!         status = 422,
16//!         title = "An invalid value was provided",
17//!         ty = "https://example.net/validation-error"
18//!     )]
19//!     InvalidValue
20//! }
21//! ```
22//!
23//! Doing so adds the response to the generated openapi specification.
24//!
25//! # Fields
26//!
27//! The following fields can be provided at this moment
28//!
29//! | Name | Field name | Required | Description |
30//! |-|-|-|-|
31//! | status | status | `true` |  The HTTP status code generated by the origin server for this occurrence of the problem |
32//! | title | title | `false` | A short, human-readable summary of the problem type |
33//! | ty | type | `false` | A URI reference [RFC3986] that identifies the problem type. |
34//! | detail | detail | `false` | A human-readable explanation specific to this occurrence of the problem. |
35
36pub use poem;
37pub use poem_openapi;
38pub use poem_openapi_problemdetails_macro::ApiProblemDetails;
39pub use problemdetails;
40pub use serde_json;