1 unstable release
Uses new Rust 2024
new 0.1.0 | May 11, 2025 |
---|
#32 in #poem
14KB
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
Name | Field name | Required | Description |
---|---|---|---|
status | status | true |
The HTTP status code generated by the origin server for this occurrence of the problem |
title | title | false |
A short, human-readable summary of the problem type |
ty | type | false |
A URI reference [RFC3986] that identifies the problem type. |
detail | detail | false |
A human-readable explanation specific to this occurrence of the problem. |
poem-openapi-problemdetails
poem-openapi-problemdetails
provides an integration layer between problemdetails
and poem_openapi
. It allows you to define and handle HTTP API problem details in a structured manner.
Example
For examples, check the examples
directory.
Contributing
Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE
file for details.
Dependencies
~30–44MB
~692K SLoC