Skip to content

add generate openapi script to support all APIs generating OpenAPI specs#1738

Draft
notrab wants to merge 1 commit intomainfrom
generic-generate-openapi-script
Draft

add generate openapi script to support all APIs generating OpenAPI specs#1738
notrab wants to merge 1 commit intomainfrom
generic-generate-openapi-script

Conversation

@notrab
Copy link
Member

@notrab notrab commented Mar 9, 2026

Lite PR

Tip: Review docs on the ENSNode PR process

Summary


Why

  • The previous generate-ensapi-openapi.ts script was hardcoded to ENSApi with a fixed output path.
  • This change makes the script app-agnostic so it can be reused by any app that exposes an @/openapi-document module.
  • The output path is now specified via a --out CLI flag instead of being baked in.

Testing

  • Verified the existing generate:openapi npm script in docs/docs.ensnode.io/package.json still produces the same ensapi-openapi.json output with the updated command.

Notes for Reviewer (Optional)

  • The script was renamed from generate-ensapi-openapi.ts to generate-openapi.ts to reflect its generic.
  • The --out flag is resolved relative to the app's root directory (i.e. the cwd when executed via pnpm --filter <app> exec).
  • Tthe script still uses the same generateOpenApi31Document() import and prettier formatting.

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)

Copilot AI review requested due to automatic review settings March 9, 2026 14:25
@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

⚠️ No Changeset found

Latest commit: b98a970

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 9, 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 9, 2026 2:26pm
ensnode.io Ready Ready Preview, Comment Mar 9, 2026 2:26pm
ensrainbow.io Ready Ready Preview, Comment Mar 9, 2026 2:26pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

The OpenAPI generation workflow was refactored to use a CLI-driven script with dynamic output path configuration. The package.json script now invokes a modified generate-openapi.ts that accepts a required --out argument instead of using hardcoded paths.

Changes

Cohort / File(s) Summary
OpenAPI Generation Configuration
docs/docs.ensnode.io/package.json
Updated generate:openapi script to invoke generate-openapi.ts with --out flag specifying output file path instead of invoking generate-ensapi-openapi.ts.
OpenAPI Script Implementation
scripts/generate-openapi.ts
Refactored to accept CLI arguments via --out flag instead of hardcoded path. Added parseArgs-based argument parsing with strict validation requiring --out parameter; exits with error code 1 if missing. Updated path resolution to use provided argument value.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • feat: generate-openapi script #1700: Previous PR that introduced the OpenAPI generation workflow; current PR refactors and replaces the earlier generate-ensapi-openapi.ts script with a new CLI-driven implementation.

Poem

🐰 A path once carved in stone so tight,
Now dances free in CLI light!
With --out flags, we hop with grace,
Each argument finds its rightful place. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: making the OpenAPI generation script generic to support all APIs rather than being ENSApi-specific.
Description check ✅ Passed The PR description follows the template structure with all required sections (Summary, Why, Testing, Notes) completed; Pre-Review Checklist is also filled out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch generic-generate-openapi-script

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.

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

Updates the monorepo’s OpenAPI generation workflow by making the generator script app-agnostic, so any app can produce an OpenAPI 3.1 spec as long as it exposes an @/openapi-document module (supporting issue #1601’s direction for shared OpenAPI tooling).

Changes:

  • Generalizes the OpenAPI generator script to require an explicit --out path and resolve it from the executing app’s working directory.
  • Updates the Mintlify docs generate:openapi script to call the new generic generator with the appropriate output path.

Reviewed changes

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

File Description
scripts/generate-openapi.ts Adds --out CLI handling and removes ENSApi-specific hardcoded output path to make the script reusable across apps.
docs/docs.ensnode.io/package.json Updates the docs OpenAPI generation command to use the new script and pass --out explicitly.
Comments suppressed due to low confidence (2)

scripts/generate-openapi.ts:19

  • The header comment says this script has “no runtime dependencies”, but it still requires external CLIs (pnpm and biome) at runtime for the formatting step. Consider rewording to clarify it has no app/runtime API deps, but does require these tools to be available on PATH.
    scripts/generate-openapi.ts:6
  • PR description says the script still uses Prettier formatting, but this script formats the output with Biome (biome format). Please update the PR description (or the script docs) to avoid confusion for future contributors.

💡 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.

Caution

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

⚠️ Outside diff range comments (1)
scripts/generate-openapi.ts (1)

54-73: 🧹 Nitpick | 🔵 Trivial

Consider using the typed error from child_process.

The type assertion on line 61 works but is slightly awkward. Node.js execFileSync throws an error with additional properties (status, signal, stderr, etc.) when the subprocess fails. You could simplify this by using the actual type.

♻️ Optional: Use a more explicit type guard
 } catch (error) {
   console.error("Error: Failed to format with Biome.");
   if (error instanceof Error) {
-    const err = error as NodeJS.ErrnoException & { status?: number };
+    const err = error as NodeJS.ErrnoException & { status?: number; signal?: string };
     if (err.code === "ENOENT") {
       console.error("'pnpm' is not available on your PATH.");
     } else if (err.status !== undefined) {
       console.error(`Biome exited with code ${err.status}.`);
       console.error(
         `Try running 'pnpm -w exec biome format --write ${outputPath}' manually to debug.`,
       );
+    } else if (err.signal) {
+      console.error(`Biome was killed by signal ${err.signal}.`);
     } else if (err.message) {
       console.error(err.message);
     }
   }
   process.exit(1);
 }

Alternatively, you could keep it as-is since the current handling covers the most common cases.

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

In `@scripts/generate-openapi.ts` around lines 54 - 73, Replace the ad-hoc type
assertion for the caught error with the standard child_process ExecException
type: in the catch block for execFileSync (around the error handling for
execFileSync/biome), cast the caught error to
import('child_process').ExecException (or import ExecException from
'child_process') instead of NodeJS.ErrnoException & { status?: number }, then
use its properties (code, status, message, stderr) in the existing checks (the
caught error variable and the checks for ENOENT, status, and message should
reference ExecException) so you use the proper typed error for subprocess
failures.
🤖 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 `@scripts/generate-openapi.ts`:
- Around line 54-73: Replace the ad-hoc type assertion for the caught error with
the standard child_process ExecException type: in the catch block for
execFileSync (around the error handling for execFileSync/biome), cast the caught
error to import('child_process').ExecException (or import ExecException from
'child_process') instead of NodeJS.ErrnoException & { status?: number }, then
use its properties (code, status, message, stderr) in the existing checks (the
caught error variable and the checks for ENOENT, status, and message should
reference ExecException) so you use the proper typed error for subprocess
failures.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bd97db2d-5e12-40d9-ae30-5b40d9033bef

📥 Commits

Reviewing files that changed from the base of the PR and between 5c64d89 and b98a970.

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

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.

2 participants