Repository navigation
feat(web): serve the REST API reference as markdown for agents - #730
Draft
dash0-dev[bot] wants to merge 9 commits into
Draft
dash0-dev[bot] wants to merge 9 commits into
dash0-dev[bot] wants to merge 9 commits into
Conversation
…kdown Add renderOpenApiMarkdown, a pure renderer that turns the generated OpenAPI document into one Markdown file: every operation with its parameters, body, responses and a minimal curl, shared shapes written once and linked, shared headers documented once. Mark X-LoreKit-Dry-Run with x-server-default: false and reword its description: the spec's default: true is only the console pre-fill, and a request without the header executes for real. Co-authored-by: dash0-dev[bot] <257284812+dash0-dev[bot]@users.noreply.github.com>
Add /api-docs.md, the OpenAPI document rendered as Markdown, and make /api-docs negotiate: a request with Accept: text/markdown gets the Markdown instead of Scalar's empty JavaScript shell. The HTML page now carries alternate links, a plain-text noscript note and a Link header (alternate + RFC 8631 service-desc) pointing at both machine formats. Co-authored-by: dash0-dev[bot] <257284812+dash0-dev[bot]@users.noreply.github.com>
Add a REST API section to llms.txt naming /api-docs.md, the OpenAPI JSON and the console, and stating that a REST write is real unless it carries X-LoreKit-Dry-Run: true. Co-authored-by: dash0-dev[bot] <257284812+dash0-dev[bot]@users.noreply.github.com>
Assert /api-docs.md, Accept: text/markdown negotiation and the HTML signposts in the api-docs journey. List /api-docs.md on the deep-links page and describe it in the web and openapi function notes. Co-authored-by: dash0-dev[bot] <257284812+dash0-dev[bot]@users.noreply.github.com>
Contributor
|
The dashboard preview for this PR — redeployed on each push that changes the web app.
Preview always points at this PR's latest commit; Deployment is the immutable build of |
Contributor
Author
✅ No issues foundRe-review at 7f5e4ae: the Accept q-parameter fix is correct and covered by tests, the description now covers both dry-run changes, and all 8 finder candidates were refuted or scored below the bar. No open threads. Review details
Memories used
Nothing to report — measurability (3 paths classified), integrations (not activated), severity, 0 files skipped.
|
Extract primaryTag/UNTAGGED, nonNullVariant, hasMeaningfulDefault and refName for logic the branch repeated; drop fieldTable's always-'Field' parameter; rename a cryptic local; trim docstrings and a six-line WHY comment to their summaries. Co-authored-by: dash0-dev[bot] <257284812+dash0-dev[bot]@users.noreply.github.com>
…s it The six POST reads (list, search, facets, pivot, activity, read) never check the header, yet the spec offered it on every POST and the Markdown said every POST without it changes data. Skip them in the spec, word the Markdown preamble from the per-operation header list, and add a guard holding the spec to each router's requires: write. Co-authored-by: dash0-dev[bot] <257284812+dash0-dev[bot]@users.noreply.github.com>
/api-docs returned its Markdown variant with s-maxage=300, so a CDN that ignored Vary: Accept could serve it to browsers for five minutes. Send it as private, no-cache; /api-docs.md stays the cacheable copy. Co-authored-by: dash0-dev[bot] <257284812+dash0-dev[bot]@users.noreply.github.com>
…lders Addresses the pr-reviewer comment: #730 (comment) Refs: #730 Co-authored-by: dash0-dev[bot] <257284812+dash0-dev[bot]@users.noreply.github.com>
A client sending text/markdown;Q=0 refused Markdown but was read as q=1 and got it anyway; parameter names are case-insensitive. Raised as an advisory (below the bar) in the pr-reviewer report on PR #730. Co-authored-by: dash0-dev[bot] <257284812+dash0-dev[bot]@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
/api-docsis a Scalar page drawn by JavaScript, so an agent that fetches it gets an empty<div id="app">and a title. The OpenAPI JSON beside it is 166 KB with every schema inlined (the error body appears 111 times). Agents need the reference in a form they can read in one pass.What changed
@lorekit/schemas/openapi/markdownrenders the generated OpenAPI document as one Markdown file (~87 KB): an endpoint index, then every operation's parameters, body, responses and a minimalcurl(path parameters as<id>, since curl globs{id}), with shared headers and schemas written once and linked./api-docs.mdserves it./api-docsreturns it toAccept: text/markdown(sentprivate, no-cache, so a CDN that ignoresVarycan't hand it to browsers), and the HTML page gains<link rel="alternate">tags, a plain-text<noscript>note and aLinkheader (alternate+ RFC 8631service-desc).X-LoreKit-Dry-Runadvertiseddefault: true(the console pre-fill) though the server executes a write without it, now markedx-server-default: false; and it was offered on six read-only POSTs (list, search, facets, pivot, activity, read) that ignore it, now dropped there. A newmcp-coreguard (rest-dry-run-parity.spec.ts) holds the spec to each router'srequires: write.llms.txtgains a REST API section pointing at/api-docs.md; the deep-links page and the web/openapi agent notes mention it.How to verify
curl -H 'Accept: text/markdown' <preview>/api-docsandcurl <preview>/api-docs.md; the page in a browser looks unchanged.pnpm nx test schemas,npx vitest run src/lib/api-docsinpackages/web,npx vitest run src/mcp-guardsinpackages/mcp-core, and theapi-docs.e2e.tsjourney.Notes for reviewers
The REST spec has almost no field-level descriptions (1 of ~400 parameters and body fields), so the Markdown shows types, enums, bounds and defaults but not what each field means; adding
.describe()to the zod schemas is the natural follow-up./polishandreview-loophave run on this branch (zero open threads).