Something went wrong. Try again.
Small, focused utilities for Rust HTTP APIs built with Axum and utoipa. The workspace favors types and generated code over runtime configura
Something went wrong. Try again.
README.md
tag_api_problem_details #
RFC 9457 problem responses for Axum and OpenAPI documentation backends.
Documentation goes through aide (feature aide, maintained, backed by
schemars) or utoipa (feature utoipa, unmaintained).
Define the errors for an endpoint once. Variant fields stay inline; no payload struct is needed:
use axum::Json;
use tag_api_problem_details::{Problem, ProblemError};
#[derive(ProblemError)]
enum UserError {
/// The requested user does not exist.
#[problem(status = 404)]
ResourceNotFound { id: String },
}
async fn get_user() -> Result<Json<User>, Problem<UserError>> {
Err(Problem(UserError::ResourceNotFound { id: "42".into() }))
}
The derive generates Axum response handling plus documentation for the enabled
backend: schemars-backed response specs consumed by aide's OperationOutput
(aide feature), or utoipa responses (utoipa feature). The response
uses application/problem+json and a generated type such as:
urn:your-package:error:user-error:resource-not-found
#[problem(namespace = "tag-api-example")] overrides the package-derived URN
namespace when needed.