OpenAPI: type SearchHitView.visibility as the Visibility enum (consistency with #29) #38

Closed
opened 2026-06-04 18:26:44 +00:00 by logaritmisk · 0 comments
Owner

Follow-up from #29 (Tier 3 typed-client). #29 enum-typed the visibility/data_type/authority-kind fields on the admin object/field/authority View DTOs, but SearchHitView.visibility (crates/api/src/admin_search.rs) is still a plain String and so generates string in web/src/api/schema.d.ts rather than the Visibility union.

Effect: web/src/search/search-result-row.tsx passes hit.visibility (typed string) to <VisibilityBadge>, which is why that component's prop stayed visibility: string rather than tightening to the union.

Ask

  • Annotate SearchHitView.visibility with #[schema(value_type = domain::Visibility)] (the domain::Visibility schema is already registered in openapi.rs from #29; domain::ToSchema is in place per #3 Option A). The runtime field stays String (the search projection builds it from the indexed string) — only the schema description changes.
  • Regenerate web/src/api/schema.d.ts; SearchHitView.visibility becomes the "draft" | "internal" | "public" union.
  • Optionally tighten VisibilityBadge's prop to the Visibility union now that every caller passes it.

Acceptance

  • SearchHitView.visibility is the Visibility union in schema.d.ts.
  • Web typecheck/tests stay green; no new casts.

Small, low-risk; the pattern is exactly the one applied in #29.

Follow-up from #29 (Tier 3 typed-client). #29 enum-typed the `visibility`/`data_type`/authority-`kind` fields on the admin object/field/authority View DTOs, but **`SearchHitView.visibility`** (`crates/api/src/admin_search.rs`) is still a plain `String` and so generates `string` in `web/src/api/schema.d.ts` rather than the `Visibility` union. Effect: `web/src/search/search-result-row.tsx` passes `hit.visibility` (typed `string`) to `<VisibilityBadge>`, which is why that component's prop stayed `visibility: string` rather than tightening to the union. ## Ask - Annotate `SearchHitView.visibility` with `#[schema(value_type = domain::Visibility)]` (the `domain::Visibility` schema is already registered in `openapi.rs` from #29; `domain::ToSchema` is in place per #3 Option A). The runtime field stays `String` (the search projection builds it from the indexed string) — only the schema description changes. - Regenerate `web/src/api/schema.d.ts`; `SearchHitView.visibility` becomes the `"draft" | "internal" | "public"` union. - Optionally tighten `VisibilityBadge`'s prop to the `Visibility` union now that every caller passes it. ## Acceptance - `SearchHitView.visibility` is the `Visibility` union in `schema.d.ts`. - Web typecheck/tests stay green; no new casts. Small, low-risk; the pattern is exactly the one applied in #29.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: logaritmisk/biggus-dickus#38