Skip to content

Feat/mic 73 openapi model - #158

Open
matthewmr-eqty wants to merge 6 commits into
feat/mic-73-docs-open-api-viewerfrom
feat/mic-73-openapi-model
Open

matthewmr-eqty wants to merge 6 commits into
feat/mic-73-docs-open-api-viewerfrom
feat/mic-73-openapi-model

Conversation

@matthewmr-eqty

@matthewmr-eqty matthewmr-eqty commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Need

Customers read guardian's three APIs on the current docs site and hold links to 146 of its pages. The viewer needs one model of each service before it can render any page.

Problem

Two of the three files are Swagger 2.0. Circular $refs cannot be stored as content. Customer links follow starlight-openapi's slug rule, which the design's own wording got wrong.

Change

A pure module with no Astro imports. Slugs copy starlight-openapi's rule exactly, and schemas become a finite tree that marks true cycles only. Samples and the Markdown twin come from the model, so a page and its twin cannot disagree. Nothing imports the module yet; the loader and pages follow in the next two PRs. swagger2openapi plus swagger-parser was rejected.

Evidence

All 146 live URLs reproduced from the pinned files. 28 new tests, including zero false recursion markers across the three real specs. Lint, format check, build and the full test suite (131 docs tests) pass on top of #157.

Not covered

No page renders yet. The model has not run inside Astro.

Flow

_api.json / _api.yaml
      │
   ingest ── Swagger 2.0 → OpenAPI 3, dereference
      │          └─ bad file → OpenApiError(file, line, fix)
      ▼
   buildModel ── slugs, tags, finite schema tree
      │
   ApiModel ──┬─ samplesFor → cURL, fetch
              └─ markdownFor → twin body

Review focus

Read src/openapi/ in this order: ingest.ts, model.ts, schema-tree.ts, then samples.ts and markdown.ts. The 13 files under tests/fixtures/openapi/ are byte copies of guardian at e87db18be, kept out of Prettier on purpose. pnpm-lock.yaml can be skipped.

matthewmr-eqty and others added 6 commits September 24, 2026 11:10
Need: the viewer is tested against the three specs customers read today.
Problem: those specs change on guardian main weekly, so live copies make tests drift.
Solution: copies pinned at guardian e87db18be, kept out of Prettier, libraries pinned exact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Need: service teams ship Swagger 2.0 and OpenAPI 3 files, and the viewer renders one shape.
Problem: a malformed file must fail the build with its name and position, not render blank.
Solution: files are upgraded to OpenAPI 3 and dereferenced in memory; failures name file, line and fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Need: service teams who hand-write Swagger YAML get their API rendered.
Problem: YAML reads unquoted `swagger: 2.0` as the number 2, so the build failed with "found 2".
Solution: the number 2 is read as Swagger 2.0 and upgraded like the quoted form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Need: customers hold links to 146 operation and overview pages, and every one must survive the switch.
Problem: the spec's own slug wording missed dots and case, and circular schemas cannot be serialised.
Solution: slugs copy starlight-openapi's rule exactly, and schemas become a finite tree that marks true cycles only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Need: customers copy a sample for every operation, and agents read each operation as Markdown.
Problem: a twin built from rendered HTML would lose the parameter tables.
Solution: samples and the twin both come from the model, so the page and its twin cannot disagree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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