Swagger Client: resolving and using OpenAPI documents in JavaScript
Javascript library to connect to swagger-enabled APIs via browser or nodejs
At a glance
- What is it?
- A JavaScript module for fetching, resolving and interacting with Swagger 2.0 and OpenAPI 3 documents, published in three builds with per-environment helper swaps. The version matrix, the runtime policy and the install-time analytics are where the interesting decisions sit.
- Who is it for?
- Swagger Client is an option for applications that fetch and resolve OpenAPI documents at runtime. Check the compatibility table and release notes for the exact version and specifications you need, test representative definitions, and review the Node and browser support policy before upgrading.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 14, 2026, and from our analysis. They are not legal advice.
Star history
- swagger-api/swagger-client2,698 ★ · +4
| Repository | 2026-09-29 | 2026-11-14 |
|---|---|---|
| swagger-api/swagger-client | 2.7k | 2.7k |
4 Stars in the last 46 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Reading the OpenAPI compatibility table
The repository's compatibility table maps client versions to specification revisions. The following is a historical excerpt; check the current table and release notes for later versions. It maps client versions to the specification revisions they handle:
| Client | Release date | Spec compatibility | | --- | --- | --- | | 3.37.x | 2026-02-27 | 2.0, 3.0.0 through 3.0.4, 3.1.0, 3.2.0 | | 3.33.x | 2024-12-30 | 2.0, 3.0.0 through 3.0.4, 3.1.0 | | 3.19.x | 2023-01-23 | 2.0, 3.0.0 through 3.0.4, 3.1.0 | | 3.10.x | 2020-01-17 | 2.0, 3.0.0 through 3.0.3 | | 2.1.32 | 2017-01-12 | 1.0, 1.1, 1.2 |
At the time of this review, the main-branch manifest was 3.38.4 while the table did not have a separate 3.38 row. Absence of a row alone does not establish a lack of support: consult release notes and test the specific OpenAPI features you need. The bottom row also points its version at a tree URL for the 2.x line while every other row links a release tag.
Node.js support follows the release calendar, so a minor can drop a runtime
The runtime requirement is Node.js `>=22`, and the library uses the native fetch implementation rather than a polyfill. Node.js 12, 14, 16, 18 and 20 are named as end of life and no longer supported.
The policy behind that line is stated in a note and is unusual enough to quote directly: the minimum Node.js runtime version aligns with the Node.js releases schedule, which is what lets the maintainers drop support for end of life versions without doing a major version bump. In other words the semver promise covers the library's API, not the set of runtimes it will start on. A patch release that raises the floor from one Node major to the next is in scope by that policy.
Browsers are handled on a different schedule and a different mechanism. The supported set is the latest Chrome, Safari, Firefox and Edge, each using its own native fetch. Between them, the two platforms have almost nothing in common except the fetch assumption.
Scarf analytics fire during installation, and two switches turn them off
Installation is observable. The project uses Scarf to collect anonymized installation analytics, states that they help support the maintainers and that they run only during installation, and gives two ways to opt out.
The first is a field in your own manifest:
{
"scarfSettings": {
"enabled": false
}
}The second is an environment variable applied to whichever npm install runs, given as `SCARF_ANALYTICS=false npm install`. Both are documented, and both are opt out rather than opt in.
The project documents the setting in the consuming project's package.json. In monorepos and alternative package managers, verify the effective configuration in the installation environment rather than assuming a particular workspace scope.
Browser mappings and the published package
Two helpers ship in a Node flavour and a browser flavour, and the `browser` field in the manifest swaps them. The map includes entries for source and generated directories:
"./src/helpers/btoa.node.js": "./src/helpers/btoa.browser.js",
"./lib/helpers/btoa.node.js": "./lib/helpers/btoa.browser.js",
"./es/helpers/btoa.node.js": "./es/helpers/btoa.browser.js"The other helper is an AbortController polyfill with the same three-way treatment, for six mappings in total in the inspected manifest. Bundlers that honor the browser field select the corresponding browser implementations.
The catch is the `files` list. It names LICENSE, NOTICE, README.md, package.json, `lib`, `es`, `dist/swagger-client.browser.js`, `dist/swagger-client.browser.min.js` and the minified sourcemap. `src` is not in it. So the three `src` entries in the browser map describe files that never reach npm, and only the `lib` and `es` pairs can fire for a consumer of the published package.
Three entry points ship: require, import and a minified unpkg bundle
The manifest resolves three different ways depending on how it is loaded:
"main": "lib/commonjs.js",
"module": "es/index.js",
"unpkg": "dist/swagger-client.browser.min.js"`main` is the CommonJS build, `module` and `jsnext:main` both point at the same ES module build, and `unpkg` names the minified browser bundle. The `files` list carries the unminified browser bundle and the sourcemap next to it, so a CDN can serve either form. The build script chain matches: `build` runs the UMD browser build, the commonjs build and the es build in sequence, and a separate `analyze:umd:browser` script points the source map explorer at the minified bundle to see what ended up inside it.
So the same source is transformed three ways, and the unpkg field points to a minified browser bundle; the appropriate artifact depends on the import path and tooling.
Features known to be missing from 3.x have their own document
The 3.x rewrite is acknowledged rather than hidden. Two documents sit under docs/migration: a migration guide for moving from 2.x to 3.x, and a second one referred to only by the name Graveyard, introduced for features known to be missing from 3.x.
The 2.x line is still reachable. Readers of the older version are pointed at the 2.x branch rather than at an archive, and the compatibility table keeps a row for 2.1.32 dated 2017-01-12 covering specification versions 1.0, 1.1 and 1.2, with a note that this release is only available on GitHub.
That gives the project an unusually honest shape: a current major, a documented list of what it dropped, and a branch for the previous one. What it does not give is a version mapping. The Graveyard names missing features without saying which client version reintroduced or permanently dropped them, so a reader has to reconcile that document against the release list by hand.
prepublishOnly runs clean, lint, test and build, and a hook checks every commit
The publish path is a single chain:
"prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build"Clean, lint, test, then build, all before anything is published. Underneath it the repository carries configuration for contributor checks, whose execution depends on the local hooks and CI setup: `.commitlintrc.json` for commit message rules, `.husky/` for git hooks, `.lintstagedrc` for staged file checks, `.eslintrc.js` and `.prettierrc` for style, `.editorconfig` for whitespace, and `.browserslistrc` for the browser targets the build targets. `.releaserc` holds the release configuration and `.nvmrc` pins the development runtime, with `config.deps_check_dir` set to `.deps_check` for a dependency check directory.
The current manifest also defines separate CommonJS, ES module and artifact-test scripts; inspect the version being built for the full command list.
Editorial conclusion
Swagger Client is an option for applications that fetch and resolve OpenAPI documents at runtime. Check the compatibility table and release notes for the exact version and specifications you need, test representative definitions, and review the Node and browser support policy before upgrading. The project documents installation analytics and opt-out settings; verify their behavior in your package manager and environment.
Frequently asked questions
What is swagger-client?
A JavaScript module that fetches, resolves and interacts with Swagger and OpenAPI documents, supporting Swagger 2.0 as well as OpenAPI 3. It runs in the browser and in Node.js, is licensed Apache 2.0, and its homepage is swagger.io. The manifest describes it as a collection of interfaces for OAI specs.
How do I use swagger-client?
This repository indexes its usage documentation rather than repeating it, under docs/usage: Installation, Tags Interface, HTTP client for OAS operations, OpenAPI Definition Resolver, HTTP Client, and Swagger Client API. Development setup and the scripts reference sit under docs/development, and the 2.x to 3.x guide and the Graveyard of missing features sit under docs/migration.
Does swagger-client collect analytics when my users install it?
It uses Scarf for anonymized installation analytics, and the project states these run only during installation and exist to support the maintainers. You can opt out by setting the `scarfSettings.enabled` field to `false` in your project's package.json, or by setting `SCARF_ANALYTICS` to `false` in the environment that installs your npm packages, for example `SCARF_ANALYTICS=false npm install`.
Which Node.js version does swagger-client require, and can a patch release raise it?
Node.js 22 or greater, using native fetch. Node.js 12, 14, 16, 18 and 20 are named as end of life and unsupported. The project states its minimum runtime version aligns with the Node.js releases schedule, which is what allows it to drop end of life versions without a major version bump.
Which OpenAPI versions does the current swagger-client support?
The project's compatibility table lists supported Swagger and OpenAPI versions by client release. It lists OpenAPI 3.2.0 from the 3.37.x line; check the current table, release notes and the exact installed version, then test the definitions and features your application uses.
How does swagger-client ship different builds for Node and the browser?
The manifest resolves three ways: `main` for CommonJS at lib/commonjs.js, `module` and `jsnext:main` for the ES module build at es/index.js, and `unpkg` for the minified browser bundle at dist/swagger-client.browser.min.js. A `browser` field swaps Node and browser variants of btoa and an AbortController polyfill across the src, lib and es directories.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/swagger-api-swagger-client)Star history chart for your README
[](https://hysenlabs.com/projects/swagger-api-swagger-client)Was this useful?