about summary refs log tree commit diff
path: root/test/python/test_openapi.py
diff options
context:
space:
mode:
authorPjotr Prins <pjotr.public01@thebird.nl>2026-10-03 12:57:40 +0000
committerPjotr <wrk@bosa.lan>2026-10-03 12:57:40 +0000
commit0a21f4876c61894c788143db8c65c3d00525243b (patch)
tree9d80b13578f2481e8c7f74f3870539df5d00db9e /test/python/test_openapi.py
parent6d2254a53e298ad3f2411252f9ffb22f38ab4676 (diff)
downloadgenenetwork4-0a21f4876c61894c788143db8c65c3d00525243b.tar.gz
Add shared ApiError response shape and request-id tracking.
* Cargo.toml (dependencies): Add tower-http, features request-id and
util.
* src/error.rs: New file.  ApiError, modeled on RFC 7807 (Problem
Details for HTTP APIs) plus code, operation_id, spec_url, request_id
and next.  type and spec_url are relative paths since this service has
no fixed public domain.  Implements axum::response::IntoResponse.
* src/lib.rs (app): Add SetRequestIdLayer and PropagateRequestIdLayer,
assigning each request an x-request-id and copying it onto the
response.
(request_id_string): New function.
(species, species_by_name): Take an Extension<RequestId> parameter.
Return Result<_, ApiError> instead of Result<_, (StatusCode, String)>.
(species_by_name): On no match, set ApiError's next to /species, so a
caller with a wrong species name can discover the valid ones.
* tests/species_by_name.rs (species_by_name_unknown_species_returns_404):
Check the full ApiError body (status, code, operation_id, spec_url,
next) and that request_id matches the x-request-id response header,
instead of only the status code.
* test/python/test_species_by_name.py
(test_species_by_name_unknown_species_returns_404): Likewise.
* README.md: Add an Error handling section documenting the ApiError
shape and each field.
* rust-package.scm: Regenerate with guix import crate -f Cargo.lock
genenetwork4.  Adds crate-source definitions for tower-http and its
new transitive dependencies.
* guix.scm (genenetwork4-git)[native-inputs]: Add rust-tower-http-0.7.1,
rust-getrandom-0.4.3 and rust-r-efi-6.0.0.
Diffstat (limited to 'test/python/test_openapi.py')
0 files changed, 0 insertions, 0 deletions