npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@powerduck/openapi-codegen

v0.6.7

Published

Generate runnable HTTP request examples from OpenAPI documents. 21 languages, 41 clients, browser-compatible, zero runtime dependencies.

Readme

@powerduck/openapi-codegen

npm version license downloads

Generate runnable HTTP request examples from OpenAPI documents. Supports 21 languages and 41 language/client combinations. Browser-compatible, zero runtime dependencies.


Powerduck is an open-source developer tooling platform for teams building modern API workflows.

  • 21 Languages — JavaScript, Python, Go, Rust, Java, PHP, Ruby, C#, F#, Kotlin, Swift, Dart, and more
  • 41 Client Combinations — fetch, axios, requests, httpx, http.client, aiohttp, Guzzle, RestSharp, and more
  • OpenAPI 3.0/3.1/3.2 — Full support for modern OpenAPI specifications
  • Security Schemes — Bearer tokens, API keys, Basic auth, OAuth2, and custom headers
  • Parameter Handling — Path, query, header, and cookie parameters with proper encoding
  • Request Bodies — JSON, form-data, x-www-form-urlencoded, and raw payloads
  • Browser Compatible — Pure TypeScript, no Node.js dependencies, works in any modern browser
  • Dual ESM/CJS — Works with import and require, with bundled TypeScript declarations

Quick Start

Install

npm install @powerduck/openapi-codegen

Generate from a document

import { generate } from "@powerduck/openapi-codegen";

const code = generate({
  document: openApiDocument,
  path: "/pets/{id}",
  method: "get",
  language: "javascript",
  client: "fetch",
});

console.log(code);

List available generators

import { list } from "@powerduck/openapi-codegen";

for (const { language, client } of list()) {
  console.log(`${language}/${client}`);
}

Provide credentials

const code = generate({
  document,
  path: "/pets/{id}",
  method: "get",
  language: "javascript",
  client: "fetch",
  securityValues: {
    bearerAuth: "your-token-here",
    apiKey: "your-api-key",
  },
});

Links


Supported Languages & Clients

| Language (language) | Clients (client) | | --------------------- | --------------------------------------------------------------- | | c | libcurl | | csharp | httpclient, restsharp | | clojure | clj-http | | dart | http | | fsharp | httpclient | | go | new-request | | http | http1 | | java | asynchttp, java-net-http, okhttp, unirest | | javascript | axios, fetch, jquery, ofetch, xhr | | kotlin | okhttp | | node | axios, fetch, ofetch, undici | | objc | nsurlsession | | ocaml | cohttp | | php | curl, guzzle, laravel-http | | powershell | invoke-restmethod, invoke-webrequest | | python | aiohttp, http-client, httpx-async, httpx-sync, requests | | r | httr2 | | ruby | net-http | | rust | reqwest | | shell | curl, httpie, wget | | swift | nsurlsession |


API Reference

generate(options)

Generate HTTP request code from an OpenAPI document.

import { generate } from "@powerduck/openapi-codegen";

const code = generate({
  document: openApiDocument,
  path: "/pets",
  method: "post",
  language: "python",
  client: "requests",
  securityValues: { bearerAuth: "token" },
});

Options

| Option | Type | Required | Description | | ---------------- | ------------------------ | -------- | ---------------------------------------------------------- | | language | string | Yes | Target language id (see the table above) | | client | string | Yes | HTTP client id (see the table above) | | document | unknown | Yes* | Parsed OpenAPI document object | | path | string | Yes* | API path (e.g. /pets/{id}) | | method | string | Yes* | HTTP method (get, post, put, delete, patch, head, options) | | request | RequestIR | No | Pre-built intermediate request; skips document normalization | | serverUrl | string | No | Override the resolved base URL | | securityValues | Record<string, string> | No | Security scheme values | | softRefMode | boolean | No | Lenient $ref resolution for partially available documents |

* Required when request is not provided. The common path is document + path + method; pass a pre-built request only when you have already normalized the operation yourself.

list()

List all available language/client combinations.

import { list } from "@powerduck/openapi-codegen";

const generators = list();
// [{ language: "javascript", client: "fetch" }, ...]

normalize(options)

Normalize one operation into the intermediate request shape and validate its inputs.

import { normalize } from "@powerduck/openapi-codegen";

const normalized = normalize({
  document: rawDocument,
  path: "/pets/{id}",
  method: "get",
});

TypeScript Types

import type {
  GenerateOptions,
  Generator,
  Parameter,
  Security,
  Body,
} from "@powerduck/openapi-codegen";

Browser Usage

<script type="module">
  import { generate, list } from "https://esm.sh/@powerduck/openapi-codegen";

  const code = generate({
    document: openApiDoc,
    path: "/users",
    method: "get",
    language: "javascript",
    client: "fetch",
  });
</script>

License

MIT © POWERDUCK LIMITED

0.6.4 — Circular parameter values

Serializing a circular deepObject query parameter now throws a descriptive TypeError instead of looping indefinitely. Shared acyclic objects are still serialized at every occurrence.

Extended HTTP methods

HTTP operation discovery includes all nine fixed OpenAPI 3.2 methods (including trace and query) and custom verbs in additionalOperations, such as PROPFIND, REPORT, and CUSTOM-VERB. Shared method helpers come from @powerduck/openapi-parser/methods; path metadata is not interpreted as an operation. Custom verbs must be valid HTTP tokens. Use OpenAPI 3.2 when declaring QUERY or additionalOperations.

Generated requests preserve custom method names. The target HTTP client/server must support the method; browser Fetch restrictions still apply to methods such as CONNECT and TRACE.