Skip to content

feat: add OpenAPI spec upload for bulk resource registration#758

Open
PurdueDM wants to merge 2 commits intoMerit-Systems:mainfrom
PurdueDM:feat/upload-openapi-spec
Open

feat: add OpenAPI spec upload for bulk resource registration#758
PurdueDM wants to merge 2 commits intoMerit-Systems:mainfrom
PurdueDM:feat/upload-openapi-spec

Conversation

@PurdueDM
Copy link
Copy Markdown

@PurdueDM PurdueDM commented Apr 3, 2026

Summary

Adds OpenAPI spec upload support to the resource registration page, allowing users to paste or upload an OpenAPI 3.x / Swagger 2.x specification to bulk-register all endpoints as x402 resources.

Fixes #97

Changes

New: OpenAPI Parser (�pps/scan/src/lib/openapi/parse-spec.ts)

  • Parses OpenAPI 3.0/3.1 and Swagger 2.0 specs (JSON)
  • Extracts all endpoints with HTTP methods, parameters, request bodies, and response schemas
  • Resolves `` references within the spec
  • Handles server variable substitution for base URL resolution
  • Supports base URL auto-detection from servers (3.x) or host/basePath (2.x)

New: tRPC Endpoint (

egisterFromOpenApi)

  • Dry-run mode — parse and preview all discovered endpoints before registering
  • Reuses existing probeX402Endpoint() + registerResource() pipeline (no new registration logic)
  • Sequential registration with 200ms rate limiting
  • Per-endpoint success/failure reporting
  • Base URL override support

New: UI Component (openapi-upload.tsx)

  • File upload via existing Dropzone component (.json, .yaml, .yml)
  • Paste textarea for copy-pasting spec content
  • Two-step flow: Parse Spec → Review endpoints → Register All
  • Endpoint preview with color-coded HTTP method badges
  • Detailed results showing which endpoints registered vs failed (with error reasons)
  • Collapsible base URL override field
  • Reset button to start over

Modified: Register Page

  • Added OpenApiUpload component below the existing RegisterResourceForm
  • No changes to existing registration flow

How it works

  1. User uploads or pastes an OpenAPI spec
  2. Click Parse Spec to preview all discovered endpoints
  3. Review the endpoint list (shows method, path, description)
  4. Click Register All to probe and register each endpoint
  5. Results show which endpoints were registered vs failed (with reasons)

Only endpoints responding with 402 get registered — others are skipped with error messages.

No new dependencies

  • Uses existing UI components (Card, Badge, Dropzone, Textarea, Collapsible)
  • Uses existing registration pipeline (probeX402Endpoint, registerResource)
  • Parser is self-contained with no external YAML/OpenAPI libraries

- Add OpenAPI 3.x / Swagger 2.x parser (lib/openapi/parse-spec.ts)
  - Extracts endpoints, parameters, request bodies, response schemas
  - Resolves $ref references and server variables
  - Base URL auto-detection from spec servers or Swagger 2.x host/basePath
- Add registerFromOpenApi tRPC endpoint with dry-run mode
  - Preview all endpoints before committing to registration
  - Sequential registration with rate limiting (200ms)
  - Reuses existing probeX402Endpoint + registerResource pipeline
- Add OpenApiUpload UI component on the register page
  - File upload (JSON/YAML) via existing Dropzone component
  - Paste textarea for copy-pasting spec content
  - Endpoint preview with HTTP method badges and descriptions
  - Per-endpoint success/failure reporting after registration
  - Base URL override for specs without server info

Fixes Merit-Systems#97
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 3, 2026

@PurdueDM is attempting to deploy a commit to the Merit Systems Team on Vercel.

A member of the Team first needs to authorize it.

…ad, FileReader error handling

- Add circular reference detection in resolveRef with visited-set to prevent DoS
- Remove YAML file accept since parser only supports JSON
- Add FileReader.onerror handler for user-facing error feedback
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.

Allow uploading of openapi spec for resources

1 participant