|
Breaking: every success body is now {"data", "meta": {"state",
"took_ms", "request_id"}, "notes", "next"}; clients read `data`. Only
`/` (plain text) and `/openapi.json` are unwrapped.
* src/response.rs (Envelope, Meta, State, Ctx, RequestInfo): handlers
take Ctx first and build the response with ctx.envelope(data), so
timing and the request id are never filled in by hand. `state` is
`complete` or `partial`; notes are server-authored only; `next` are
concrete relative hrefs (path_segment percent-encodes names).
* src/routes/*.rs, src/lib.rs (version): every handler returns
Envelope<..> with next links; /search is `partial` when the locus
lookup fails or a sorted 1000-hit window may be truncated, and
/publications/{pubmed_id}/traits when datasets were left out for
authorization.
* src/error.rs (ApiError): add `took_ms`, an RFC 7807 extension member.
* src/auth.rs (AuthToken): the 401 now carries request_id and took_ms
(it never had a request_id); Ctx stores RequestInfo in the request
extensions for it.
* tests: common::data / envelope_data parse every success body through
the envelope; tests/envelope.rs and test/python/test_envelope.py check
the shape, errors, and that every `next` link resolves;
tests/envelope_partial.rs checks the `partial` search without a
database; tests/openapi.rs fails if a JSON success response is not an
Envelope_* schema.
* README.md, docs/SKILL.md, docs/gn-auth.md, RELEASE_NOTES.md: document
the envelope and took_ms on errors.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
|
* .gitignore: Add __pycache__.
* src/lib.rs (app): Add /version route.
(VersionInfo, version): New struct and handler, returning name,
short_name, version, release, date, and git as a JSON record.
* build.rs: New file. Embeds GN4_GIT_HASH and GN4_COMMIT_DATE via
cargo:rustc-env, read from git rev-parse and git show of HEAD.
* Cargo.toml (dependencies): Add serde with derive feature.
[dev-dependencies]: Add serde_json.
* tests/version.rs: New file.
* test/python/server_test_case.py: New file. ServerTestCase,
wait_for_port, BINARY, HOST, PORT moved here from
test/python/test_hello_world.py.
* test/python/test_hello_world.py: Use server_test_case.ServerTestCase
instead of duplicating setUpClass and tearDownClass.
* test/python/test_version.py: New file.
* guix.scm: Add (gnu packages version-control) to use-modules.
(genenetwork4-git)[native-inputs]: Add git-minimal.
(genenetwork4-git)[arguments]<#:phases>[python-rest-test]: Run
test/python with python3 -m unittest discover instead of invoking
test_hello_world.py directly, so test_version.py also runs.
|