-
Notifications
You must be signed in to change notification settings - Fork 15
feat(docs): OpenAPI spec sync with CI validation and PR previews #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
Changes from 16 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
f493d51
3945545
a16f9eb
7ad6563
91dfe3c
600294a
21b72af
bba27af
692a119
b640ca9
16a641f
87c5180
ac91cff
4e11eb8
8ac20f5
83ae0ba
f7d7031
0d1d1d5
367c991
ffb49ae
1a94122
5d7e8ee
e59fb6f
4037d9f
9d1bf2a
5cade8d
5965d3f
f287094
42a19d0
731b4fe
690b155
09bf81d
546d0f4
e82231a
a5ed508
ab00660
57261ce
6bd4d09
419468c
e14ef97
32ea6a4
76cab69
3d37753
41c95b2
c69b37a
cf0fc54
5d563ea
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 |
|---|---|---|
|
|
@@ -48,7 +48,46 @@ | |
| - uses: ./.github/actions/setup_node_environment | ||
| - run: pnpm test | ||
|
|
||
| openapi-sync-check: | ||
| name: "OpenAPI Spec Sync Check" | ||
| runs-on: blacksmith-4vcpu-ubuntu-2204 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: ./.github/actions/setup_node_environment | ||
|
|
||
| - name: Start ENSApi in OpenAPI CI check mode | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| run: | | ||
| OPENAPI_CI_CHECK=true pnpm --filter ensapi start & | ||
| # Wait for server to be ready | ||
| for i in {1..30}; do | ||
| if curl -s http://localhost:4334/openapi.json > /dev/null 2>&1; then | ||
| echo "ENSApi is ready" | ||
| break | ||
| fi | ||
| echo "Waiting for ENSApi to start... ($i/30)" | ||
| sleep 1 | ||
| done | ||
vercel[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
coderabbitai[bot] 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
|
||
| - name: Generate OpenAPI spec from local build | ||
| working-directory: docs/docs.ensnode.io | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| run: pnpm openapi:generate http://localhost:4334 | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - name: Verify OpenAPI spec matches committed version | ||
| run: | | ||
| if git diff --quiet docs/docs.ensnode.io/openapi.json; then | ||
| echo "✅ OpenAPI spec is in sync with codebase" | ||
| else | ||
| echo "❌ OpenAPI spec is out of sync" | ||
| echo "" | ||
| echo "The committed openapi.json differs from what ENSApi generates:" | ||
| echo "" | ||
| git diff --color docs/docs.ensnode.io/openapi.json | ||
| echo "" | ||
| echo "Run 'OPENAPI_CI_CHECK=true pnpm --filter ensapi start' then 'pnpm --filter @docs/mintlify openapi:generate http://localhost:4334' and commit the changes." | ||
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
|
||
| exit 1 | ||
| fi | ||
|
|
||
| integrity-check: | ||
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium test
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
|
||
| name: "Integrity Check" | ||
| runs-on: blacksmith-4vcpu-ubuntu-2204 | ||
| services: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,4 +21,6 @@ export type EnsApiEnvironment = Omit<DatabaseEnvironment, "DATABASE_SCHEMA"> & | |
| PortEnvironment & | ||
| LogLevelEnvironment & | ||
| TheGraphEnvironment & | ||
| EnsHolidayAwardsEnvironment; | ||
| EnsHolidayAwardsEnvironment & { | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| OPENAPI_CI_CHECK?: string; | ||
|
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,34 +2,61 @@ | |
|
|
||
| [docs.ensnode.io](https://docs.ensnode.io) runs on [Mintlify](https://mintlify.com). | ||
|
|
||
| ## Local Development | ||
| Learn more about [ENSNode](https://ensnode.io) from [the "Starlight" ENSNode docs](https://ensnode.io/docs/). Everything from these "Starlight" docs is planned to be transitioned into these Mintlify docs soon. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider splitting the long introductory sentence for readability. This line is quite long. A line break or splitting into two sentences would improve readability in raw Markdown. 🤖 Prompt for AI Agents |
||
|
|
||
| ### Getting Started | ||
| ## API Docs | ||
|
|
||
| This Mintlify site serves two (potentially distinct) sets of API docs from two sources: | ||
|
|
||
| | 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 | ||
|
|
||
| We use a combination of runtime URLs and committed files to keep API docs in sync across environments. This setup achieves: | ||
|
|
||
| 1. Clone the repository: | ||
| - 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 | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Each branch has its own `openapi.json`, validated by the CI to be in sync with the `openapi.json` that would actually be returned by the code for ENSApi in the same branch. | ||
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
|
||
|
|
||
| ```bash | ||
| git clone https://github.com/namehash/ensnode.git | ||
| ``` | ||
| ### Generating the Spec | ||
|
|
||
| 2. Navigate to the docs directory: | ||
| To generate the OpenAPI spec, you need a running ENSApi instance. For local development without external dependencies, use the `OPENAPI_CI_CHECK` mode: | ||
|
|
||
| ```bash | ||
| cd ensnode/docs/docs.ensnode.io | ||
| ``` | ||
| ```bash | ||
| # Start ENSApi in CI check mode (no external dependencies required) | ||
| OPENAPI_CI_CHECK=true pnpm --filter ensapi start | ||
|
|
||
| 3. Start the local development server: | ||
| # In another terminal, generate the spec | ||
| pnpm --filter docs.ensnode.io openapi:generate http://localhost:4334 | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
Comment on lines
+46
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify the working directory for the generation script. The "Generating the Spec" section follows the "Local Development" section which instructs Consider adding a note like "Run from the repository root:" above the code block to prevent confusion. 🤖 Prompt for AI Agents |
||
|
|
||
| ```bash | ||
| pnpm mint dev | ||
| ``` | ||
| The URL argument is required — there is no default to avoid accidentally generating from the wrong source. | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### CI Validation | ||
|
|
||
| CI runs an `openapi-sync-check` job that starts ENSApi in `OPENAPI_CI_CHECK` mode and compares the generated spec against the committed `openapi.json`. If they differ, the check fails. | ||
|
|
||
| Update the committed spec when you've changed API routes or schemas. | ||
|
|
||
| ## 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 +65,4 @@ Changes pushed to the main branch are automatically deployed to production. | |
| ## Resources | ||
|
|
||
| - [Mintlify documentation](https://mintlify.com/docs) | ||
| - [ENSNode "Starlight" docs](https://ensnode.io/docs/) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,13 @@ | |
| }, | ||
| { | ||
| "group": "API Reference", | ||
| "openapi": "https://gist.githubusercontent.com/notrab/94b637e77468cbddd895d7933ce88f64/raw/12cb5ed183558a9bdda5d1c7004db6c794dbd13e/green-ensnode-openapi.json" | ||
| "openapi": "https://api.alpha.ensnode.io/openapi.json" | ||
| }, | ||
| { | ||
| "group": "Preview", | ||
| "pages": ["ensapi/preview"], | ||
| "openapi": "./openapi.json", | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "hidden": true | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update the description of this PR to include a section for post-merge follow-up actions. This needs to include the following goal:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted. You can’t have a page only hidden in production but visible in previews using |
||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ] | ||
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. | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| For the production API documentation, see the [API Reference](/ensapi). | ||
Uh oh!
There was an error while loading. Please reload this page.