Skip to content

feat(collections): show a dataset's JSON schema in a modal - #364

Open
jirhiker wants to merge 1 commit into
stagingfrom
feature/dataset-json-schema-modal
Open

feat(collections): show a dataset's JSON schema in a modal#364
jirhiker wants to merge 1 commit into
stagingfrom
feature/dataset-json-schema-modal

Conversation

@jirhiker

Copy link
Copy Markdown
Member

What

Adds a Schema button to every row of the datasets catalog (both table and card views). It opens the collection's published JSON Schema — GET /ogcapi/collections/{id}/schema?f=json — as a readable field table: name, title, OGC role, type, description, and enum values. A Raw JSON toggle and a copy button cover the case where the document itself is what the reader wants.

Also hides the desktop-GIS surfaces on this page (see below).

Why the field table is the default view

The server fills in per-property title and description for these collections, and a raw JSON dump buries them. The schema is read far more often to answer "what columns does this dataset have and what do they mean" than to be copied verbatim — so the readable view leads and the raw document is one toggle away.

Shape details the renderer has to handle

  • A geometry property arrives with a format (geometry-any) and no type, so the type label falls back to format.
  • Controlled vocabularies run to two dozen entries; enum chips are capped at six with the remainder behind a tooltip.
  • Below the tablet breakpoint the three-column table pushes descriptions off-screen, so narrow screens get a stacked per-field layout instead.
  • The dialog keeps its target through MUI's closing transition — clearing it on close flashed an empty "0 fields" shell on the way out.

Hand-written zod, deliberately

collectionSchema.ts hand-writes the schema types, the same way gisArtifacts.ts does. The committed openapi-auth.json snapshot describes none of the /ogcapi paths, so src/generated cannot describe this response. Replace with generated schemas once the OGC surface lands in the deployed spec.

Desktop GIS hidden

The connections panel, the table's Desktop GIS column, and the per-card download links are now gated behind a single SHOW_DESKTOP_GIS = false constant in list.tsx. The catalog data still loads (the collection index keys off it), so flipping the constant back to true restores all three together. The table's last column is renamed Map → Actions and the group-band colSpan follows the flag.

The sidebar's "Connect Desktop GIS" link is a separate page and is untouched.

Verification

  • npm run typecheck clean.
  • npm run test:run — 434 passed, 1 skipped, including 13 new tests across collectionSchema.test.ts and CollectionSchemaDialog.test.tsx.
  • Lint clean on changed files. The one warning in list.tsx (sortOgcCollections unused) is pre-existing on staging.
  • Exercised in the browser against the local API at desktop and mobile widths: modal opens from both views, both toggles render, close is clean, no console errors.

🤖 Generated with Claude Code

Each row in the datasets catalog gets a Schema button that opens the
collection's published JSON Schema
(`/ogcapi/collections/{id}/schema?f=json`) as a readable field table:
name, title, OGC role, type, description, and enum values. A Raw JSON
toggle and a copy button cover the case where the document itself is
what the reader wants.

The field table is the default view because the server fills in
per-property titles and descriptions that a raw JSON dump buries, and
the schema is read far more often to answer "what columns does this
dataset have" than to be copied verbatim.

Two shape details the renderer has to handle: a geometry property
arrives with a `format` and no `type`, so the type label falls back to
format; and controlled vocabularies run to two dozen entries, so enum
chips are capped with the remainder behind a tooltip. Below the tablet
breakpoint the three-column table is replaced by a stacked per-field
layout, which a phone can actually read.

The schema types are hand-written zod, like `gisArtifacts.ts`: the
committed `openapi-auth.json` snapshot describes none of the `/ogcapi`
paths, so `src/generated` cannot describe this response yet.

Also hides the desktop-GIS connections panel, table column, and
per-card download links behind a single `SHOW_DESKTOP_GIS` constant.
The catalog data still loads — the collection index keys off it — so
flipping the constant back to `true` restores all three together.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

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