@powerduck/x-to-openapi
@powerduck/x-to-openapi is a production-grade, extensible TypeScript framework that converts source formats — curl commands and Postman Collections (v2.0 / v2.1.0) — into valid OpenAPI 3.2 documents. It is built for CI pipelines, API documentation generation, and reverse-engineering HTTP traffic.
It builds on @powerduck/openapi-parser for document validation and upgrade to OpenAPI 3.2.
- Version:
- License: MIT
- Node.js requirement:
>= 18.0.0 - Output: OpenAPI 3.2.0 only
- Source: github.com/powerducklab/x-to-openapi
What it does
curl command ─┐
├─► CurlAdapter ─┐
│ │
Postman collection ─► PostmanAdapter ─► NormalizedRequest[]
│
▼
buildOpenApi32() ─► OpenAPI 3.2 document
│
▼
validateOpenApi32() ─► diagnostics
- An adapter parses a source (curl text, a Postman collection) into a list of
NormalizedRequestobjects. - The builder merges requests by method + path, infers schemas, path parameters, and security, and produces an OpenAPI 3.2 document.
- The validator checks the output against the OpenAPI schema (via
@powerduck/openapi-parser) and reports diagnostics.
Features
- Two built-in adapters —
CurlAdapter(single, batch, and browser "Copy all as cURL" output) andPostmanAdapter(v2.0/v2.1.0, nested folders, auth inheritance). - Zero-config helpers —
curlToOpenApiandpostmanToOpenApiregister an adapter and convert in one call. - OpenAPI 3.2 output — every generated document is
openapi: "3.2.0"and validated. - Multi-request merging — same method+path operations are combined; query/header/cookie params and body schemas are structurally merged.
- Path parameter inference — numeric IDs, UUIDs, ULIDs, and long hex segments are templated (
/users/{userId}) when they vary across at least N samples. - Security inference — Bearer, Basic, and API key (header/query/cookie) detection with proper
securitySchemes. - All body types — JSON, XML, form-urlencoded, multipart/form-data (text + file), GraphQL, text, binary.
- Postman test-script preservation —
pm.test()/pm.expect()are emitted asx-postman-scriptson each operation. - Diagnostics — every issue carries a severity, code, and source index;
strictmode throws on errors. - Extensible — implement
SourceAdapterto add HAR, HTTPie, or Insomnia sources.