-
Notifications
You must be signed in to change notification settings - Fork 15
openapi spec / docs poc #1550
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
base: main
Are you sure you want to change the base?
openapi spec / docs poc #1550
Changes from 5 commits
237de51
9045cc6
cc5f236
ddc8bf6
9da0a88
3ae1447
61b4438
06c49c5
66e4b1e
30dff75
67ff063
c75e78f
aaf1a73
80f06e0
630309f
ab5927b
fa0119d
bdca6ea
fac4754
1973ef6
911bc3c
f1dd11d
b1cea1a
323e565
98bece8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||||||||||||||||||
| #!/usr/bin/env tsx | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Generate OpenAPI spec from a running ENSApi instance. | ||||||||||||||||||||||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * Usage: | ||||||||||||||||||||||
| * pnpm openapi:generate # Uses default URL (production) | ||||||||||||||||||||||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| * pnpm openapi:generate http://localhost:3223 # Uses custom URL | ||||||||||||||||||||||
| * ENSAPI_URL=http://localhost:3223 pnpm openapi:generate | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * Output: | ||||||||||||||||||||||
| * Writes openapi.json to the docs directory for Mintlify to consume. | ||||||||||||||||||||||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| * Run `pnpm biome format --write docs/docs.ensnode.io/openapi.json` after to format. | ||||||||||||||||||||||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
| */ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import { writeFileSync } from "node:fs"; | ||||||||||||||||||||||
| import { resolve } from "node:path"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const DEFAULT_ENSAPI_URL = "https://api.alpha.ensnode.io"; | ||||||||||||||||||||||
| const OUTPUT_PATH = resolve(import.meta.dirname, "../../../docs/docs.ensnode.io/openapi.json"); | ||||||||||||||||||||||
|
||||||||||||||||||||||
| import { resolve } from "node:path"; | |
| const DEFAULT_ENSAPI_URL = "https://api.alpha.ensnode.io"; | |
| const OUTPUT_PATH = resolve(import.meta.dirname, "../../../docs/docs.ensnode.io/openapi.json"); | |
| import { resolve, dirname } from "node:path"; | |
| import { fileURLToPath } from "node:url"; | |
| const DEFAULT_ENSAPI_URL = "https://api.alpha.ensnode.io"; | |
| const __dirname = dirname(fileURLToPath(import.meta.url)); | |
| const OUTPUT_PATH = resolve(__dirname, "../../../docs/docs.ensnode.io/openapi.json"); |
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my other comment that suggested we might apply formatting within the API route handler such that it's not necessary to perform additional formatting of the response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formatting is correct for the API response as JSON.stirngify, so we should really only be using Biome in our CI check to validate they're equal by formatting them both there. Or do I not understand the request here.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,58 @@ | ||
| # ENSNode Documentation | ||
| # ENSNode API Documentation | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| [docs.ensnode.io](https://docs.ensnode.io) runs on [Mintlify](https://mintlify.com). | ||
| [docs.ensnode.io](https://docs.ensnode.io) hosts the ENSApi reference documentation. | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Local Development | ||
| Learn more about [ENSNode](https://ensnode.io) from [the ENSNode docs](https://ensnode.io/docs/). | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Getting Started | ||
| ## Architecture | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The documentation serves API reference from two sources: | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| | Section | Source | Purpose | | ||
| | -------------------- | ------------------ | ------------------------------------------- | | ||
| | **API Reference** | Production API URL | Always reflects the live deployed API | | ||
| | **Preview** (hidden) | `./openapi.json` | PR preview deployments for upcoming changes | | ||
|
|
||
| When you change API routes or schemas, update the committed `openapi.json` to preview changes in Mintlify's PR deployments. | ||
|
|
||
| ## OpenAPI Spec Management | ||
|
|
||
| 1. Clone the repository: | ||
| We use a combination of runtime URLs and committed files to keep API docs in sync across environments. This setup achieves: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/namehash/ensnode.git | ||
| ``` | ||
| - Production API docs match the production deployment, even when production lags behind `main` | ||
| - Non-API docs stay in sync with `main` through normal Git flow | ||
|
||
| - Each branch has its own `openapi.json`, validated by CI | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - PR previews show upcoming API changes before merge | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 2. Navigate to the docs directory: | ||
| ### Generating the Spec | ||
|
|
||
| ```bash | ||
| cd ensnode/docs/docs.ensnode.io | ||
| ``` | ||
| ```bash | ||
| # Generate from production API | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pnpm --filter ensapi openapi:generate | ||
| ``` | ||
|
|
||
| 3. Start the local development server: | ||
| ### CI Validation | ||
|
|
||
| ```bash | ||
| pnpm mint dev | ||
| ``` | ||
| CI runs an `openapi-sync-check` job that compares the committed `openapi.json` against production. If they differ, the check fails. | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Update the committed spec when: | ||
|
|
||
| - You've changed API routes or schemas (generate from your local instance) | ||
| - Production was updated (generate from production) | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Local Development | ||
|
|
||
| ### Getting Started | ||
|
|
||
| 1. `git clone https://github.com/namehash/ensnode.git` | ||
| 2. `cd docs/docs.ensnode.io` | ||
| 3. `pnpm mint dev` | ||
| 4. Open [http://localhost:3000](http://localhost:3000) in your browser | ||
|
|
||
| ### Troubleshooting | ||
|
|
||
| - If a page loads as a 404, make sure you are running in a folder with a valid `docs.json`. | ||
| - Run `pnpm mint --help` to read more details about Mintlify CLI. | ||
| - If a page loads as a 404, ensure you're running in a folder with a valid `docs.json` | ||
| - Run `pnpm mint --help` for more Mintlify CLI details | ||
|
|
||
| ## Publishing Changes | ||
|
|
||
|
|
@@ -38,3 +61,4 @@ Changes pushed to the main branch are automatically deployed to production. | |
| ## Resources | ||
|
|
||
| - [Mintlify documentation](https://mintlify.com/docs) | ||
| - [ENSNode documentation](https://ensnode.io/docs/) | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||||||||||||||
| --- | ||||||||||||||||||
| title: API Preview | ||||||||||||||||||
| sidebarTitle: Preview | ||||||||||||||||||
| description: Preview upcoming API changes from the current branch. | ||||||||||||||||||
| --- | ||||||||||||||||||
|
|
||||||||||||||||||
| This page shows the OpenAPI specification from the current branch, which may include unreleased API changes. | ||||||||||||||||||
|
Comment on lines
+4
to
+7
|
||||||||||||||||||
| description: Preview upcoming API changes from the current branch. | |
| --- | |
| This page shows the OpenAPI specification from the current branch, which may include unreleased API changes. | |
| description: Preview upcoming API changes from this branch. | |
| --- | |
| This page shows the OpenAPI specification for this branch (for pull requests, the PR's head branch), which may include unreleased API changes. |
Uh oh!
There was an error while loading. Please reload this page.