Skip to content

Migrate remaining APIs to Huma (fort scan draft + tier 3/4)#369

Merged
jfberry merged 19 commits into
feat/huma-pokemon-v2-v3-scanfrom
feat/huma-remaining-apis
Jun 5, 2026
Merged

Migrate remaining APIs to Huma (fort scan draft + tier 3/4)#369
jfberry merged 19 commits into
feat/huma-pokemon-v2-v3-scanfrom
feat/huma-remaining-apis

Conversation

@jfberry

@jfberry jfberry commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #368 (feat/huma-pokemon-v2-v3-scan) — it reuses that PR's Huma infrastructure (ApiLatLon, setupHumaAPI, the golbatSecret scheme, goccy serializer, body logger). Review/merge #368 first; this targets that branch and should be retargeted to main once #368 lands.

Summary

Migrates ~18 remaining /api endpoints from gin to Huma, so the whole API is documented in OpenAPI / browsable at /docs.

  • Fort scan (/api/{gym,pokestop,station,fort}/scan) — served via Huma with a Draft badge (Stoplight x-badges), fort_in_memory 503 gating, and the int8/int16 fort DNF range types unified into one.
  • Pokemon/api/pokemon/search and /api/pokemon/id/{pokemon_id} (v1 /pokemon/scan left on gin, deprecated).
  • Tier 3 reads — gym/station query, gym search, gym/pokestop/tappable by-id, pokestop-positions.
  • Tier 4 operationalquest-status, clear-quests, devices/all, fort-tracker/{cell,forts}, reload-geojson (GET+POST), skip-preserve-pokemon (GET+POST).

Response structs converted to pointer-based (so Huma documents them; golden-snapshot tests pin the wire format): ApiGymResult, ApiPokestopResult, ApiStationResult, ApiTappableResult. ApiFortScan and ApiPokemonSearch now use ApiLatLon (fixing the same geo.Location lat/lon bug).

Still on gin (intentional): /raw, /health, /version, v1 /pokemon/scan, /pokemon/available.

Notable behavior changes (consistent across the migration)

  • Validation errors are now 422 + application/problem+json (was ad-hoc 400/500 {"error":...}).
  • Malformed geofence on pokestop-positions/quest-status400 (was 500); short-circuits before any DB call.
  • gym/query / station/query accept only {"ids":[...]} (legacy bare-array form dropped).
  • clear-quests DB-delete behavior verified identical; all per-endpoint success status codes (200/202) preserved.

Test Plan

Automated (CI): golden-snapshot wire-compat for each converted struct, humatest e2e (auth/status/envelope) per group, OpenAPI registration + draft-badge assertions. go test ./..., go build -tags go_json ./..., go vet ./... all green.

Manual (live DB):

  • Boot against a populated MariaDB; open /docs and confirm operations group by tag and the 4 fort scan ops show the orange Draft badge.
  • Smoke a representative endpoint per group (fort scan, a by-id get, a query, a geofence endpoint).
  • Confirm clear-quests still deletes within the geofence as before.

Design + plan: docs/superpowers/specs/2026-05-30-huma-remaining-apis-design.md, docs/superpowers/plans/2026-05-30-huma-remaining-apis.md

🤖 Generated with Claude Code

jfberry and others added 19 commits May 30, 2026 20:36
Fort scan (draft-badged) + pokemon search/id + tier 3 reads + tier 4
operational endpoints. Pointer-based response structs everywhere (pokemon
template), reusing existing builders and the PR #368 Huma infrastructure.
Stacked on feat/huma-pokemon-v2-v3-scan.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
13 tasks in 3 phases: shared infra (fort range unification, ApiLatLon,
draft-badge + geofence helpers) -> fort scan (draft) -> pokemon search/id
+ tier 3 -> tier 4. Pointer-based result structs with golden snapshots;
geofence endpoints via RawBody + NormaliseFenceFromBytes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
All planned endpoints (fort scan draft-badged, pokemon search/id, tier 3,
tier 4) now served by Huma; v1 scan + /raw + health/version stay on gin.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Register available-pokemon (GET, 202) and retire the gin handler. The
result struct (ApiPokemonAvailableResult) is plain ints, so no pointer
conversion needed — just doc tags.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The quest-status, clear-quests, and pokestop-positions bodies are JSON
(GeoJSON geometry/feature or a Golbat fence), but Huma's RawBody []byte
documented them as application/octet-stream (a binary string). Switch to
Body json.RawMessage so the OpenAPI shows application/json. json.RawMessage
is assignable to []byte, so NormaliseFenceFromBytes is called unchanged;
malformed JSON still returns 400 (Huma body-parse error).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jfberry jfberry merged commit 06555dd into feat/huma-pokemon-v2-v3-scan Jun 5, 2026
5 checks passed
@jfberry jfberry deleted the feat/huma-remaining-apis branch June 5, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant