-
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
Draft
notrab
wants to merge
46
commits into
main
Choose a base branch
from
openapi-spec-generator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
openapi spec / docs poc #1550
Changes from 4 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
237de51
poc
notrab 9045cc6
dummy preview page
notrab cc5f236
fix new line
notrab ddc8bf6
fmt new spec
notrab 9da0a88
update readme for docs site
notrab 3ae1447
Apply suggestions from code review
notrab 61b4438
move generator file
notrab 06c49c5
remove local dev env arg
notrab 66e4b1e
update ci check
notrab 30dff75
lint
notrab 67ff063
fix frozen lock
notrab c75e78f
lint spec
notrab aaf1a73
update readme
notrab 80f06e0
add colored diff
notrab 630309f
test diff
notrab ab5927b
lint
notrab fa0119d
revert
notrab bdca6ea
readme
notrab fac4754
deploy switch
notrab 1973ef6
run the openapi-check
notrab 911bc3c
add changeset
notrab f1dd11d
continue-on-error
notrab b1cea1a
update readme structure
notrab 323e565
Merge branch 'main' into openapi-spec-generator
notrab 98bece8
update spec
notrab f493d51
announce mintlify errors in slack
notrab 3945545
retry on transient errors
notrab a16f9eb
rename environment variable
notrab 7ad6563
update wording
notrab 91dfe3c
make right config types
notrab 600294a
remove mintlify comment
notrab 21b72af
update readme variable secret comment
notrab bba27af
add node types
notrab 692a119
update preview text
notrab b640ca9
rename types
notrab 16a641f
update mintlify deploy failed comment
notrab 87c5180
replace mock databaseurl for openapi generation
notrab ac91cff
check server readiness
notrab 4e11eb8
update openapi.json
notrab 8ac20f5
update docs
notrab 83ae0ba
apply coderabbit suggestion
notrab f7d7031
Merge branch 'main' into openapi-spec-generator
notrab 0d1d1d5
revert to simpler times
notrab 367c991
tidy
notrab ffb49ae
EnsApiConfigInput
notrab 1a94122
add openapi mock config
notrab 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
Some comments aren't visible on the classic Files Changed page.
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,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"); | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| async function main() { | ||
| // Get URL from argument or environment variable | ||
| const ensapiUrl = process.argv[2] || process.env.ENSAPI_URL || DEFAULT_ENSAPI_URL; | ||
| const openapiUrl = `${ensapiUrl}/openapi.json`; | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| console.log(`Fetching OpenAPI spec from: ${openapiUrl}`); | ||
|
|
||
| const response = await fetch(openapiUrl); | ||
|
|
||
| if (!response.ok) { | ||
| console.error(`Failed to fetch OpenAPI spec: ${response.status} ${response.statusText}`); | ||
| process.exit(1); | ||
| } | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const spec = await response.json(); | ||
|
|
||
| // Pretty-print the JSON for readability in git diffs | ||
| const content = `${JSON.stringify(spec, null, 2)}\n`; | ||
notrab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| writeFileSync(OUTPUT_PATH, content, "utf-8"); | ||
|
|
||
| console.log(`OpenAPI spec written to: ${OUTPUT_PATH}`); | ||
| console.log(`Spec version: ${spec.info?.version}`); | ||
| console.log(`Paths: ${Object.keys(spec.paths || {}).length}`); | ||
| } | ||
|
|
||
| main().catch((error) => { | ||
| console.error("Error generating OpenAPI spec:", error); | ||
| process.exit(1); | ||
| }); | ||
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,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). | ||
Oops, something went wrong.
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.