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

@jegan321/openapi-typescript-codegen

v0.26.0

Published

Library that generates Typescript clients based on the OpenAPI specification. Fork of ferdikoomen/openapi-typescript-codegen

Readme

OpenAPI TypeScript Codegen

Fork of ferdikoomen/openapi-typescript-codegen. See that repository for more documentation.

List of changes

  1. Headers are always optional, whether the OpenAPI JSON says they are required or not.
  2. Added an optional config property called ERROR_CALLBACK which is a function that will run before API errors are thrown.
  3. Ability to run code before or after each request using BEFORE_REQUEST and BEFORE_REQUEST config.
  4. Added --modelsImportPath to configure service model imports. Combine with --exportModels false to share models across clients.
  5. The Fetch client accepts synchronous or asynchronous BEFORE_REQUEST hooks (void | Promise<void>) and waits for them to complete before preparing and sending the request. If the hook throws or rejects, the request rejects without being sent.

Testing

  1. Run npm test to run automated tests
  2. If a snapshot test fails due to an intentional change, run npm run test:update to update the snapshots
  3. To test local changes with your application, first run npm run build. Then, replace npx @jegan321/openapi-typescript-codegen with node ../openapi-typescript-codegen/bin/index.js in your application-side script.

Release

  1. Update package.json with a new version
  2. npm run release
  3. npm publish
  4. Commit changes

Fetch runtime extensions

Generated fetch OpenAPIConfig accepts these optional settings (other transports do not):

  • ON_REQUEST(promise, options): observes the actual returned CancelablePromise, synchronously before return. Return a synchronous cleanup function to run once on fulfillment, rejection, or cancellation. Observer/cleanup exceptions are ignored. Cleanup runs in a promise microtask; use both settlement branches rather than an ignored finally() to avoid unhandled rejections.
  • ON_RESPONSE(response, options): called as soon as fetch returns any HTTP response, including 4xx/5xx, before reading its body. Do not consume the body in this hook.
  • ON_TRANSPORT_ERROR(error, options): observes fetch rejection only, excluding intentional cancellation. Setup, BEFORE_REQUEST, parsing, HTTP errors, and other hook failures are excluded.
  • TRANSFORM_TRANSPORT_ERROR(error, options): returns the rejection value to use after transport observation. Without it the original value is preserved, including non-Error values.
  • QUERY_SERIALIZER(query): returns the entire query suffix, including ? (or an empty string). Default serialization continues to use bracket notation.

All hooks are synchronous except the existing awaited BEFORE_REQUEST. Response and transport hook exceptions reject the request; they should not throw unless that is intended. Lifecycle callbacks and cleanup must be synchronous. Existing AFTER_REQUEST and ERROR_CALLBACK behavior is unchanged. No generated service signature changes are needed.

Example application-owned mobile setup (imports and network policy belong in the app):

import { OpenAPI } from './api-clients/core/OpenAPI';
import type { CancelablePromise } from './api-clients/core/CancelablePromise';
import { reportNetworkSuccess, reportNetworkFailure } from './services/network-service';
import { NetworkError } from './errors/network-error';

export const pendingRequests = new Set<CancelablePromise<any>>();
OpenAPI.ON_REQUEST = promise => {
    pendingRequests.add(promise);
    return () => { pendingRequests.delete(promise); };
};
OpenAPI.ON_RESPONSE = () => { reportNetworkSuccess(); };
OpenAPI.ON_TRANSPORT_ERROR = () => { reportNetworkFailure(); };
OpenAPI.TRANSFORM_TRANSPORT_ERROR = error => new NetworkError(error);
OpenAPI.QUERY_SERIALIZER = query => {
    const pairs: string[] = [];
    const visit = (key: string, value: any) => {
        if (value === undefined || value === null) return;
        if (Array.isArray(value)) value.forEach(item => visit(key, item));
        else if (typeof value === 'object') {
            Object.entries(value).forEach(([field, item]) => visit(`${key}_${field}`, item));
        } else pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
    };
    Object.entries(query).forEach(([key, value]) => visit(key, value));
    return pairs.length ? `?${pairs.join('&')}` : '';
};
export function cancelPendingRequests() {
    for (const promise of pendingRequests) promise.cancel();
    pendingRequests.clear();
}

Adapt the NetworkError constructor to the app's accepted input type. Apps that classify only some fetch rejections as connectivity failures can apply their predicate in both transport hooks.

Cancellation while an asynchronous BEFORE_REQUEST is pending settles the returned promise and triggers cleanup immediately; the hook itself is not abortable. Its later rejection is caught and cannot become a transport notification or an unhandled rejection. If it completes, the existing cancellation check prevents fetch. Cancellation after fetch starts aborts its signal and suppresses transport reporting/transformation, even if the rejection arrives later. A response that wins the cancellation race can still be observed. Existing CancelablePromise cancellation semantics are unchanged; no generator hook can cancel side effects inside application hooks. A never-settling hook needs application-owned cancellation/timeouts.