Skip to content

Allow uploading of OpenAPI spec for resources#645

Open
285729101 wants to merge 1 commit intoMerit-Systems:mainfrom
285729101:feat/openapi-spec-upload
Open

Allow uploading of OpenAPI spec for resources#645
285729101 wants to merge 1 commit intoMerit-Systems:mainfrom
285729101:feat/openapi-spec-upload

Conversation

@285729101
Copy link
Copy Markdown

Adds support for uploading/pasting OpenAPI specs to bulk-register x402 resource endpoints. Resolves #97.

What this does

  • New OpenAPI spec parser (lib/openapi/parse-spec.ts) that handles both JSON and YAML formats, extracts endpoints with their methods, query params, body schemas, and response schemas
  • New registerFromOpenAPISpec tRPC endpoint with dry-run mode so users can preview what will be registered before committing
  • UI component on the register page with file upload + paste textarea, base URL override, and detailed results showing which endpoints succeeded/failed
  • Only endpoints responding with 402 get registered (others are skipped with clear error messages)

How it works

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

The parser handles $ref resolution, server variable substitution, and nested schema extraction. No new dependencies needed - the YAML parser is a lightweight built-in that covers the OpenAPI subset.

Parse OpenAPI 3.x specs (JSON/YAML) and register endpoints as x402 resources.
Includes dry-run preview mode, file upload, and paste support.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 18, 2026

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

A member of the Team first needs to authorize it.

try {
const response = await fetch(
endpoint.url.replace('{', '').replace('}', ''),
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SSRF vulnerability in register and registerFromOpenAPISpec endpoints allows attackers to make the server fetch arbitrary URLs including localhost, private IPs, and internal services

Fix on Vercel

try {
const response = await fetch(
endpoint.url.replace('{', '').replace('}', ''),
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

URL path parameters are incorrectly stripped instead of being replaced with values, creating invalid endpoints

Fix on Vercel

}

// Register each endpoint
const results = await Promise.allSettled(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Potential DoS vulnerability: Promise.allSettled() spawns unlimited concurrent HTTP requests when processing OpenAPI specs with hundreds of endpoints

Fix on Vercel

@285729101
Copy link
Copy Markdown
Author

@jasonhedman the spec parser auto-discovers endpoints and generates resource entries with a dry-run preview before committing. Let me know if you want any changes to the import flow.

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