Skip to content

feat: OpenAPI spec upload for bulk resource registration#745

Open
Manishcs076 wants to merge 1 commit intoMerit-Systems:mainfrom
Manishcs076:feat/openapi-spec-registration
Open

feat: OpenAPI spec upload for bulk resource registration#745
Manishcs076 wants to merge 1 commit intoMerit-Systems:mainfrom
Manishcs076:feat/openapi-spec-registration

Conversation

@Manishcs076
Copy link
Copy Markdown

Summary

Adds an endpoint to upload OpenAPI specs and bulk-register all extracted endpoints as x402 resources.

Fixes #97

Endpoint

POST /api/resources/register-from-openapi

{
  "spec": { "openapi": "3.1.0", "paths": { ... } },
  "baseUrl": "https://example.com",
  "dryRun": false
}

Features

  • Parses OpenAPI 3.0/3.1 and Swagger 2.0 specs (JSON)
  • Extracts all endpoints with HTTP methods from paths
  • Dry-run mode — preview extracted endpoints before registering
  • Rate-limited sequential registration (200ms between requests)
  • Base URL resolution from spec servers or explicit override
  • Proper error responses (400 validation, 500 internal)

Changes

  • New file: apps/scan/src/app/api/resources/register-from-openapi/route.ts (287 lines)
  • No changes to existing code — reuses registerResource() and probeX402Endpoint()

Adds POST /api/resources/register-from-openapi that accepts an OpenAPI
3.x/Swagger 2.0 spec and bulk-registers all extracted endpoints as
x402 resources.

Features:
- Parses OpenAPI 3.0/3.1 and Swagger 2.0 specs (JSON)
- Extracts all endpoints with HTTP methods from paths
- Dry-run mode to preview endpoints before registering
- Rate-limited sequential registration to avoid overwhelming upstream
- Base URL resolution from spec servers or explicit override
- Proper error responses for invalid specs, missing base URL, etc.

Usage:
  POST /api/resources/register-from-openapi
  { "spec": { openapi spec }, "baseUrl": "https://...", "dryRun": false }

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

vercel bot commented Mar 27, 2026

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

A member of the Team first needs to authorize it.


// ===== Internal helpers =====

function resolveBaseUrl(
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.

Relative server URLs in OpenAPI spec cause crashes due to missing URL absoluteness validation

Fix on Vercel

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