jsonapi_axum 1.0.0-rc.1

axum adapter for jsonapi_core: JSON:API extractors, responders, and tower layers built on jsonapi_http
Documentation
[package]
name = "jsonapi_axum"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
description = "axum adapter for jsonapi_core: JSON:API extractors, responders, and tower layers built on jsonapi_http"
documentation = "https://docs.rs/jsonapi_axum"
keywords = ["jsonapi", "json-api", "axum", "web", "rest"]
categories = ["web-programming"]
readme = "README.md"

# Thin binding: nearly all logic lives in jsonapi_http. axum uses
# default-features = false — only the extractor/responder traits are needed here;
# the server runtime (tokio/http1) is a dev-dependency concern for the example.
[dependencies]
jsonapi_core = { path = "../jsonapi_core", version = "1.0.0-rc.1" }
jsonapi_http = { path = "../jsonapi_http", version = "1.0.0-rc.1" }
axum = { version = "0.8", default-features = false }
http = "1"
bytes = "1"
# `derive` powers the relationship-document responder's serialization repr (G6).
serde = { version = "1", features = ["derive"] }
serde_json = "1"
# The NormalizeErrorsLayer is a tower layer that unifies response bodies exactly
# like jsonapi_http's guard layers; default-features = false keeps only the
# Service/Layer traits (util is a test-only concern).
tower = { version = "0.5", default-features = false }
http-body = "1"
http-body-util = "0.1"
# Decoding the request query string to preserve sort/filter/fields/include in
# pagination links (G7).
percent-encoding = "2"

# --- Optional error-integration deps (all off by default) ---
# G11: aggregate `validator::ValidationErrors` into JSON:API 422 errors.
validator = { version = "0.20", optional = true, default-features = false }
# G12: `From<anyhow::Error>` for ergonomic `?` in handlers.
anyhow = { version = "1", optional = true }
# G12: only the `sqlx::Error` type is needed; default-features = false avoids
# pulling in a runtime or driver.
sqlx = { version = "0.8", optional = true, default-features = false }
# G13: fallback correlation-id generation when no upstream id is present.
uuid = { version = "1", optional = true, default-features = false, features = ["v4"] }

[features]
# Map `validator::ValidationErrors` into aggregated JSON:API 422 errors (G11).
validator = ["dep:validator"]
# `From<anyhow::Error> for JsonApiError` = 500 (G12).
anyhow = ["dep:anyhow"]
# `From<sqlx::Error> for JsonApiError`: RowNotFound → 404, else 500 (G12).
sqlx = ["dep:sqlx"]
# Include the raw error text in an `internal` 500's `detail`. Off by default so
# internal messages never leak to clients; enable only for local debugging.
debug-errors = []
# Let `RequestIdLayer::generate` mint a UUID when no upstream request id exists (G13).
uuid = ["dep:uuid"]
# Atomic Operations extension responder (`AtomicJsonApiResponse`); forwards to
# jsonapi_core's atomic types.
atomic-ops = ["jsonapi_core/atomic-ops"]
# In-process test utilities (`jsonapi_axum::testing`, G17). Off by default so the
# default build stays lean; enable in your `[dev-dependencies]`. Pulls in tower's
# `util` (for `oneshot`) on top of the always-present `serde_json`.
testing = ["tower/util"]

[dev-dependencies]
tower = { version = "0.5", features = ["util"] }
pollster = "0.4"
# Server runtime for the CRUD example only (feature-unified onto the lib's
# default-features=false axum for example/test builds; never affects consumers).
axum = { version = "0.8", features = ["tokio", "http1"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros", "net"] }
# Example composes `RequestIdLayer` with tower-http's `SetRequestIdLayer` to mint
# and propagate an `x-request-id` (the recommended pairing).
tower-http = { version = "0.6", features = ["request-id"] }

[lints]
workspace = true

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]