Skip to content

feat: generate-openapi script#1700

Open
notrab wants to merge 21 commits intomainfrom
generate-openapi-spec
Open

feat: generate-openapi script#1700
notrab wants to merge 21 commits intomainfrom
generate-openapi-spec

Conversation

@notrab
Copy link
Member

@notrab notrab commented Mar 1, 2026

Lite PR

Tip: Review docs on the ENSNode PR process

Summary

  • Add scripts/generate-ensapi-openapi.ts script that generates a static OpenAPI 3.1 JSON spec from the existing generateOpenApi31Document() function
  • Add generate:openapi script to root package.json for running the generators (recursively)
  • Output is written to docs/docs.ensnode.io/ensapi-openapi.json and formatted with Biome
  • Follows {appname}-openapi.json naming convention per Set foundation for multiple OpenAPI.json files #1600, ready for future specs
  • Removes the local development server from the OpenAPI Spec servers array, slight regression, but unblocks next stages to compare spec diffs

Why

  • Replaces manually-uploaded Gist with a generated-from-source committed spec
  • pnpm openapi:generate sets foundation for multiple specs per Set foundation for multiple OpenAPI.json files #1600 (recursive lookup for each service spec commands)
  • Enables PR preview builds to reference the committed spec without depending on a running server

Testing

  • Ran pnpm generate:openapi — produces docs/docs.ensnode.io/ensapi-openapi.json with Biome formatting
  • Verified output contains all route groups and operations

Notes for Reviewer (Optional)

  • Generation script reuses generateOpenApi31Document() which has zero runtime deps (stub handlers, no config/env)
  • Static spec is identical to live /openapi.json minus the localhost server entry (posted in Slack about this)
  • **Not done: CI check to verify committed spec stays in sync

Pre-Review Checklist (Blocking)

  • This PR does not introduce significant changes and is low-risk to review quickly.
  • Relevant changesets are included (or are not required). This doesn't yet warrant a changeset, only when we add to CI.

@notrab notrab requested a review from a team as a code owner March 1, 2026 10:11
Copilot AI review requested due to automatic review settings March 1, 2026 10:11
@changeset-bot
Copy link

changeset-bot bot commented Mar 1, 2026

⚠️ No Changeset found

Latest commit: aeeec50

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Contributor

vercel bot commented Mar 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
admin.ensnode.io Ready Ready Preview, Comment Mar 3, 2026 8:09pm
ensnode.io Ready Ready Preview, Comment Mar 3, 2026 8:09pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ensrainbow.io Skipped Skipped Mar 3, 2026 8:09pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

Adds a TypeScript OpenAPI generation script and npm tasks, changes ENSApi OpenAPI generation to a no-argument form, annotates route schemas with OpenAPI metadata via @hono/zod-openapi, and updates docs config/README to reference the generated OpenAPI JSON and a new hidden Preview page.

Changes

Cohort / File(s) Summary
Docs config & output
docs/docs.ensnode.io/docs.json, docs/docs.ensnode.io/ensapi-openapi.json
Replaced API Reference openapi URL with https://api.alpha.ensnode.io/openapi.json; added hidden "Preview" group that references ensapi-openapi.json (new generated artifact).
Docs content
docs/docs.ensnode.io/README.md, docs/docs.ensnode.io/ensapi/preview.mdx
Rewrote local development steps into a numbered getting-started flow, added external ENSNode "Starlight" link, and added a new ensapi/preview.mdx preview page.
OpenAPI generation scripts & npm tasks
scripts/generate-ensapi-openapi.ts, docs/docs.ensnode.io/package.json, package.json
Added generate:openapi scripts (top-level and docs site) and a new TS script that calls the ENSApi generator, writes docs/docs.ensnode.io/ensapi-openapi.json, and runs Biome formatting with robust error handling and logging.
ENSApi OpenAPI generation
apps/ensapi/src/openapi-document.ts, apps/ensapi/src/index.ts
Changed generateOpenApi31Document to no-arg signature and removed merging of additional servers; updated index to call the no-arg generator.
Route/schema OpenAPI metadata
apps/ensapi/src/handlers/*, apps/ensapi/src/lib/handlers/params.schema.ts
Replaced zod/v4 imports with @hono/zod-openapi (consolidated imports), and added .openapi(...) annotations to various query/body schema fields (pagination, boolean flags, distances, defaults) to expose types, mins/maxes, and defaults in OpenAPI.
New docs artifact
docs/docs.ensnode.io/ensapi-openapi.json (generated)
New target output produced by the script (added reference in docs.json and preview page).

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer
  participant Script as generate:openapi script
  participant Generator as ENSApi OpenAPI generator
  participant FS as Filesystem
  participant Biome as Biome (via pnpm)

  Dev->>Script: run `pnpm run generate:openapi`
  Script->>Generator: call generateOpenApi31Document()
  Generator-->>Script: returns OpenAPI 3.1 JSON
  Script->>FS: write `docs/docs.ensnode.io/ensapi-openapi.json`
  Script->>Biome: run `pnpm --silent --filter docs ... biome format ...`
  Biome-->>Script: success / failure
  Script-->>Dev: log result / exit
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through code with tiny paws,

spun a spec without a pause,
JSON baked and nicely groomed,
a hidden preview gently bloomed,
docs and APIs — hooray, applause!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: generate-openapi script' accurately and clearly summarizes the main change: adding a script to generate OpenAPI specifications, which is the primary objective of this PR.
Description check ✅ Passed The PR description follows the Lite PR template with all required sections: Summary (with 4 specific bullets), Why (rationale with issue reference), Testing (manual verification steps), Notes for Reviewer (including caveats), and Pre-Review Checklist (both items checked).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch generate-openapi-spec

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel vercel bot temporarily deployed to Preview – admin.ensnode.io March 1, 2026 10:14 Inactive
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io March 1, 2026 10:14 Inactive
@vercel vercel bot temporarily deployed to Preview – ensnode.io March 1, 2026 10:14 Inactive
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mintlify has no scope to go to the monorepo directory, so we need to symlink tpo it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like Mintlify still can't follow the symlink. Will try another method.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a generated-from-source, committed OpenAPI 3.1 spec for ENSApi and wires it into docs + scripts to support preview builds and future multi-spec expansion across the monorepo.

Changes:

  • Add an ENSApi script to generate a static OpenAPI 3.1 document and commit the generated spec at openapi/ensapi-openapi.json.
  • Add generate:openapi scripts at the app and monorepo root for easy regeneration.
  • Update Mintlify docs config to point the live API reference at the production OpenAPI endpoint and add a hidden preview group that references the committed spec file.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
package.json Bumps pinned pnpm version and adds a root generate:openapi script.
apps/ensapi/package.json Adds generate:openapi script for ENSApi.
apps/ensapi/scripts/generate-openapi.ts New generator script that writes the spec and formats it.
openapi/ensapi-openapi.json Newly committed generated OpenAPI 3.1 spec.
docs/docs.ensnode.io/docs.json Points API Reference to live OpenAPI endpoint and adds hidden preview spec reference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/ensapi/scripts/generate-openapi.ts`:
- Around line 19-20: The path for outputPath is brittle because it uses
hardcoded "../../.." traversal from __dirname; replace that with a robust root
discovery (e.g., implement a findMonorepoRoot function that walks parent
directories from dirname(fileURLToPath(import.meta.url)) or uses an env var like
MONOREPO_ROOT) and then build outputPath by resolve(monorepoRoot, "openapi",
"ensapi-openapi.json"); update references to __dirname/outputPath to use
fileURLToPath, dirname, and the new findMonorepoRoot (or env fallback) so the
script no longer depends on the file's exact relative depth.

In `@docs/docs.ensnode.io/docs.json`:
- Around line 30-31: The "Preview" group in docs.json references a non-existent
page "ensapi/preview" in its "pages" array; either remove "ensapi/preview" from
the "pages" array in the Preview group configuration or create a matching docs
file (e.g., add ensapi/preview.mdx) with the expected frontmatter and content so
the reference resolves; locate the "group": "Preview" entry and update its
"pages" array or add the new "ensapi/preview.mdx" file accordingly.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d7fb07 and 98b752d.

📒 Files selected for processing (5)
  • apps/ensapi/package.json
  • apps/ensapi/scripts/generate-openapi.ts
  • docs/docs.ensnode.io/docs.json
  • openapi/ensapi-openapi.json
  • package.json

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 1, 2026

Greptile Summary

This PR adds automated OpenAPI spec generation, replacing the manually-uploaded Gist with a source-generated committed spec that enables PR preview builds.

Key Changes:

  • Added scripts/generate-ensapi-openapi.ts that generates a static OpenAPI 3.1 JSON spec from the existing generateOpenApi31Document() function
  • Simplified generateOpenApi31Document() by removing the additionalServers parameter for cleaner separation of static vs. runtime server configuration
  • Added generate:openapi npm scripts at both root and docs package levels for easy spec regeneration
  • Updated docs.json to reference the live API endpoint instead of a static Gist, and added a hidden preview section for PR builds
  • Created ensapi/preview.mdx page to document the preview functionality
  • Follows the {appname}-openapi.json naming convention to support multiple specs per Set foundation for multiple OpenAPI.json files #1600

Implementation Quality:

  • The generation script properly handles errors, creates directories recursively, and formats output with Biome
  • TypeScript path aliases (@/openapi-document) are correctly resolved via tsx with the ensapi tsconfig
  • The generated 2,052-line spec file is valid JSON and contains all expected route groups and operations
  • The approach reuses existing code and has no runtime dependencies (uses stub handlers)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is clean, well-structured, and follows established patterns. All changes are additive (new script, new docs) or simplifying (removing unused parameter). The generated spec is committed and valid. No security concerns, runtime risks, or breaking changes identified.
  • No files require special attention

Important Files Changed

Filename Overview
scripts/generate-ensapi-openapi.ts New script that generates OpenAPI spec from source, with proper error handling and path resolution
apps/ensapi/src/openapi-document.ts Simplified generateOpenApi31Document to remove additionalServers parameter, cleaner API
docs/docs.ensnode.io/package.json Added generate:openapi script that executes the generation script via tsx in ensapi context
docs/docs.ensnode.io/docs.json Updated main API reference from Gist to live API, added hidden preview section using committed spec
docs/docs.ensnode.io/ensapi-openapi.json Generated OpenAPI 3.1 spec with 2052 lines, contains all route groups and operations

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[pnpm generate:openapi] --> B[docs package script]
    B --> C[Execute tsx in ensapi context]
    C --> D[scripts/generate-ensapi-openapi.ts]
    D --> E[generateOpenApi31Document]
    E --> F[Create stub routes]
    F --> G[Generate OpenAPI 3.1 JSON]
    G --> H[Write to ensapi-openapi.json]
    H --> I[Format with Biome]
    I --> J[Committed spec file]
    J --> K[docs.json references spec]
    K --> L[Preview page displays spec]
Loading

Last reviewed commit: 9019bef

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copilot AI review requested due to automatic review settings March 1, 2026 12:22
@vercel vercel bot temporarily deployed to Preview – ensnode.io March 1, 2026 12:22 Inactive
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io March 1, 2026 12:22 Inactive
@vercel vercel bot temporarily deployed to Preview – admin.ensnode.io March 1, 2026 12:22 Inactive
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

The trace and accelerate Zod schemas use boolstring (which accepts string input) but set .default(false) with a boolean value, causing OpenAPI schema type/default mismatch

Fix on Vercel

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +39 to +47
{
"schema": {
"description": "Maximum acceptable worst-case indexing distance in seconds"
},
"required": false,
"description": "Maximum acceptable worst-case indexing distance in seconds",
"name": "maxWorstCaseDistance",
"in": "query"
}
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the committed OpenAPI spec, the maxWorstCaseDistance query parameter schema is missing a concrete type (it only has a description). This makes the spec harder to validate and can break client generation. Consider adjusting the underlying Zod/OpenAPI metadata so this parameter emits a type: number (and any relevant constraints) in the generated spec.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also valid feedback from Copilot. Please take the lead in solving it for us.

Comment on lines +1914 to +1925
{
"schema": { "type": "string", "default": false },
"required": false,
"name": "trace",
"in": "query"
},
{
"schema": { "type": "string", "default": false },
"required": false,
"name": "accelerate",
"in": "query"
}
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trace and accelerate query parameters are emitted as type: string with default: false in the OpenAPI spec. This type/default mismatch is confusing for docs and can cause issues for client generators. Consider updating the underlying parameter schema/OpenAPI annotations so these flags are represented as booleans (or keep them as strings but use a string default like "false").

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is valid feedback from Copilot. Please take the lead in solving it for us.

Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@notrab Excited for this. Reviewed and shared feedback please merge when ready.

// Format with Biome for consistency
console.log("Formatting with Biome...");
try {
execFileSync("pnpm", ["-w", "exec", "biome", "format", "--write", outputPath], {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any special reason why not just pnpm lint? See https://github.com/namehash/ensnode/blob/b0de5e9cda0f2919aa201e1ec26a05a6473dc03c/package.json#L7C6-L7C10

Please ignore if not relevant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lightwalker-eth the current action formats a single file, where as pnpm lint targets the entire repo.

I remember a while back we were hesitant to run such commands in CI, so I opted to stay focused on the file we were writing here.

Comment on lines +46 to +54
console.error("Error: Failed to format with Biome.");
if (error instanceof Error) {
const err = error as NodeJS.ErrnoException & { status?: number };
if (err.code === "ENOENT") {
console.error("'pnpm' or 'biome' is not available on your PATH.");
} else if (err.status !== undefined) {
console.error(`Biome exited with code ${err.status}.`);
console.error("Try running 'pnpm biome format --write' manually to debug.");
} else if (err.message) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review this feedback from Copilot and take the lead in deciding if / how to action it.

"scripts": {
"mint": "pnpm dlx mint@^4.1.0"
"mint": "pnpm dlx mint@^4.1.0",
"generate:openapi": "pnpm --filter ensapi exec tsx --tsconfig tsconfig.json ../../scripts/generate-ensapi-openapi.ts"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we should be documenting this in the related README.md file?

Comment on lines +1914 to +1925
{
"schema": { "type": "string", "default": false },
"required": false,
"name": "trace",
"in": "query"
},
{
"schema": { "type": "string", "default": false },
"required": false,
"name": "accelerate",
"in": "query"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is valid feedback from Copilot. Please take the lead in solving it for us.

Comment on lines +39 to +47
{
"schema": {
"description": "Maximum acceptable worst-case indexing distance in seconds"
},
"required": false,
"description": "Maximum acceptable worst-case indexing distance in seconds",
"name": "maxWorstCaseDistance",
"in": "query"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also valid feedback from Copilot. Please take the lead in solving it for us.

@vercel vercel bot temporarily deployed to Preview – admin.ensnode.io March 3, 2026 08:17 Inactive
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io March 3, 2026 08:17 Inactive
@vercel vercel bot temporarily deployed to Preview – ensnode.io March 3, 2026 08:17 Inactive
Copilot AI review requested due to automatic review settings March 3, 2026 08:24
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/ensapi/src/handlers/amirealtime-api.routes.ts (1)

28-36: ⚠️ Potential issue | 🟡 Minor

OpenAPI type doesn't match runtime validation.

The OpenAPI metadata specifies type: "integer" but z.coerce.number() accepts any numeric value including floats. This creates a contract mismatch between the documented API and actual behavior.

If integers are intended, add .int() to the Zod chain. If floats are acceptable for durations, change OpenAPI type to "number".

Option A: Enforce integers at runtime
         .pipe(
           z.coerce
             .number({
               error: "maxWorstCaseDistance query param must be a number",
             })
+            .int({
+              error: "maxWorstCaseDistance query param must be an integer",
+            })
             .pipe(makeDurationSchema("maxWorstCaseDistance query param")),
         )
         .openapi({ type: "integer", minimum: 0 })
Option B: Allow floats in OpenAPI spec
-        .openapi({ type: "integer", minimum: 0 })
+        .openapi({ type: "number", minimum: 0 })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/ensapi/src/handlers/amirealtime-api.routes.ts` around lines 28 - 36, The
OpenAPI type for the maxWorstCaseDistance query param is "integer" but the
runtime schema uses z.coerce.number() which allows floats; update the Zod chain
for the maxWorstCaseDistance parameter (the z.coerce.number() call that then
pipes into makeDurationSchema) to enforce integers by adding .int() (e.g.,
z.coerce.number().int().pipe(...)), so the runtime validation (in the code that
references maxWorstCaseDistance and makeDurationSchema) matches the openapi({
type: "integer" }) metadata; alternatively, if floats are intended, change
openapi({ type: "integer" }) to openapi({ type: "number" }) to match
z.coerce.number().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/ensapi/src/handlers/amirealtime-api.routes.ts`:
- Around line 28-36: The OpenAPI type for the maxWorstCaseDistance query param
is "integer" but the runtime schema uses z.coerce.number() which allows floats;
update the Zod chain for the maxWorstCaseDistance parameter (the
z.coerce.number() call that then pipes into makeDurationSchema) to enforce
integers by adding .int() (e.g., z.coerce.number().int().pipe(...)), so the
runtime validation (in the code that references maxWorstCaseDistance and
makeDurationSchema) matches the openapi({ type: "integer" }) metadata;
alternatively, if floats are intended, change openapi({ type: "integer" }) to
openapi({ type: "number" }) to match z.coerce.number().

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 233fb5e and b19b199.

📒 Files selected for processing (7)
  • apps/ensapi/src/handlers/amirealtime-api.routes.ts
  • apps/ensapi/src/lib/handlers/params.schema.ts
  • docs/docs.ensnode.io/ensapi-openapi.json
  • docs/docs.ensnode.io/ensapi/preview.mdx
  • docs/docs.ensnode.io/package.json
  • package.json
  • scripts/generate-ensapi-openapi.ts

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

withReferral parameter uses .default(false) with boolean value instead of .prefault("false") for string-based boolstring parser, causing OpenAPI spec type mismatch

Fix on Vercel

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestions:

  1. File imports z from 'zod/v4' but uses .openapi() method which is only available from '@hono/zod-openapi'
  1. Files importing z from zod/v4 but using .openapi() method which is only available from @hono/zod-openapi

Fix on Vercel

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@notrab
Copy link
Member Author

notrab commented Mar 3, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Line 23: Update the package.json script named "generate:openapi" to run pnpm
recursively but skip packages that don't define that script by adding the
--if-present flag; replace the current command "pnpm -r generate:openapi" with
"pnpm -r --if-present generate:openapi" so recursive execution tolerates
packages missing the generate:openapi script.

In `@scripts/generate-ensapi-openapi.ts`:
- Around line 1-10: Add a CI check that prevents OpenAPI spec drift by running
the existing generate:openapi script (which invokes generateOpenApi31Document in
scripts/generate-ensapi-openapi.ts) during PR/CI and failing the job if the
generated artifact changes; implement this by adding a step that runs `pnpm
generate:openapi` and then `git diff --exit-code <output-filename>` (replace
<output-filename> with the committed ensapi-openapi.json artifact name) so any
divergence causes CI to fail.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 233fb5e and 91fc80b.

📒 Files selected for processing (12)
  • apps/ensapi/src/handlers/amirealtime-api.routes.ts
  • apps/ensapi/src/handlers/ensanalytics-api-v1.routes.ts
  • apps/ensapi/src/handlers/ensanalytics-api.routes.ts
  • apps/ensapi/src/handlers/name-tokens-api.routes.ts
  • apps/ensapi/src/handlers/registrar-actions-api.routes.ts
  • apps/ensapi/src/handlers/resolution-api.routes.ts
  • apps/ensapi/src/lib/handlers/params.schema.ts
  • docs/docs.ensnode.io/ensapi-openapi.json
  • docs/docs.ensnode.io/ensapi/preview.mdx
  • docs/docs.ensnode.io/package.json
  • package.json
  • scripts/generate-ensapi-openapi.ts

Comment on lines +1 to +10
/**
* Generates a static OpenAPI 3.1 JSON document for ENSApi.
*
* Usage: pnpm generate:openapi
*
* Output: docs/docs.ensnode.io/ensapi-openapi.json
*
* This script has no runtime dependencies — it calls generateOpenApi31Document()
* which uses only stub route handlers and static metadata.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Add a CI drift check for committed OpenAPI output.

Since this script produces a committed artifact, add a CI step that runs generation and fails on diff to prevent spec drift.

Example check:
pnpm generate:openapi && git diff --exit-code docs/docs.ensnode.io/ensapi-openapi.json

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/generate-ensapi-openapi.ts` around lines 1 - 10, Add a CI check that
prevents OpenAPI spec drift by running the existing generate:openapi script
(which invokes generateOpenApi31Document in scripts/generate-ensapi-openapi.ts)
during PR/CI and failing the job if the generated artifact changes; implement
this by adding a step that runs `pnpm generate:openapi` and then `git diff
--exit-code <output-filename>` (replace <output-filename> with the committed
ensapi-openapi.json artifact name) so any divergence causes CI to fail.

notrab and others added 2 commits March 3, 2026 20:08
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"docker:build:ensapi": "docker build -f apps/ensapi/Dockerfile -t ghcr.io/namehash/ensnode/ensapi:latest .",
"otel-desktop-viewer": "docker run -p 8000:8000 -p 4317:4317 -p 4318:4318 davetron5000/otel-desktop-viewer:alpine-3"
"otel-desktop-viewer": "docker run -p 8000:8000 -p 4317:4317 -p 4318:4318 davetron5000/otel-desktop-viewer:alpine-3",
"generate:openapi": "pnpm -r --if-present generate:openapi"
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions running pnpm openapi:generate, but the repo script added here is generate:openapi. Consider updating the PR description/README to match the actual command (or add an alias script if you want to support both names).

Copilot uses AI. Check for mistakes.
"description": "Resolves ENS records for a given name",
"parameters": [
{ "schema": { "type": "string" }, "required": true, "name": "name", "in": "path" },
{ "schema": { "type": "string" }, "required": false, "name": "name", "in": "query" },
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated spec documents /api/resolve/records/{name} with both a path parameter named name and a query parameter also named name (used for field selection). Even though this is technically allowed (different in), it’s very confusing for API consumers and makes the docs ambiguous. Consider renaming the selection query parameter (e.g. includeName) and updating the route/query parsing accordingly so the OpenAPI output is clearer.

Suggested change
{ "schema": { "type": "string" }, "required": false, "name": "name", "in": "query" },
{ "schema": { "type": "string" }, "required": false, "name": "includeName", "in": "query" },

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@tk-o tk-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants