Repository navigation
improvement(api): publish an RFC 9727 API catalog and stop padding tables in docs markdown #9066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { NextResponse } from 'next/server' | ||
| import { getBaseUrl } from '@/lib/core/utils/urls' | ||
| import { withRouteHandler } from '@/lib/core/utils/with-route-handler' | ||
| import { DOCS_URL } from '@/lib/help-links' | ||
|
|
||
| /** RFC 9727 §4.2: the catalog is a Linkset carrying the RFC's profile. */ | ||
| const API_CATALOG_CONTENT_TYPE = | ||
| 'application/linkset+json; profile="https://www.rfc-editor.org/info/rfc9727"' | ||
|
|
||
| /** | ||
| * RFC 9727 API catalog: one machine-readable entry point to the v2 REST API, linking its OpenAPI | ||
| * document (`service-desc`), reference docs (`service-doc`), and health endpoint (`status`) with | ||
| * the RFC 8631 relations. The anchor is this deployment's own origin, so a self-hosted instance | ||
| * describes itself. The OpenAPI document is the one published contract; its `servers` names Sim | ||
| * Cloud, so a client of another deployment uses the anchor as its base URL, as the API docs say. | ||
| * `Link: rel="api-catalog"` makes a HEAD request discoverable too (RFC 9727 §2). | ||
| */ | ||
| export const GET = withRouteHandler(() => { | ||
| const baseUrl = getBaseUrl() | ||
| const catalogUrl = `${baseUrl}/.well-known/api-catalog` | ||
|
|
||
| return NextResponse.json( | ||
| { | ||
| linkset: [ | ||
| { | ||
| anchor: `${baseUrl}/api/v2`, | ||
| 'service-desc': [ | ||
| { href: `${DOCS_URL}/openapi.json`, type: 'application/vnd.oai.openapi+json' }, | ||
| ], | ||
| 'service-doc': [{ href: `${DOCS_URL}/api-reference/getting-started`, type: 'text/html' }], | ||
| status: [{ href: `${baseUrl}/api/health`, type: 'application/json' }], | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| headers: { | ||
| 'Content-Type': API_CATALOG_CONTENT_TYPE, | ||
| 'Cache-Control': 'public, max-age=86400', | ||
| Link: `<${catalogUrl}>; rel="api-catalog"`, | ||
| }, | ||
| } | ||
| ) | ||
| }) | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.