Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .claude/skills/add-oas-version.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Add OpenAPI/Swagger Version Support

**Skill Name:** `add-oas-version`
**Purpose:** Guide the process of adding support for a new OpenAPI/Swagger specification version to swagger-js
**Purpose:** Guide the process of adding support for a new OpenAPI/Swagger specification version to swagger-client
**Based on:** Analysis of OAS 3.1.0 implementation (commits ace708ac through 56df8f61)

## Overview
Expand All @@ -10,7 +10,7 @@ This skill provides a systematic approach to adding support for a new OpenAPI/Sw

## Background: How OAS 3.1.0 Support Was Added

OpenAPI 3.1.0 support was added to swagger-js between December 2022 and January 2023. The implementation introduced a fundamentally new approach using the ApiDOM library ecosystem instead of the legacy SpecMap resolution engine.
OpenAPI 3.1.0 support was added to swagger-client between December 2022 and January 2023. The implementation introduced a fundamentally new approach using the ApiDOM library ecosystem instead of the legacy SpecMap resolution engine.

### Key Implementation Details

Expand Down Expand Up @@ -210,7 +210,7 @@ class OpenAPIJsonXYParser extends Parser {

**3.3 Implement HTTP Resolver**

Create a custom HTTP resolver using swagger-js HTTP client:
Create a custom HTTP resolver using swagger-client HTTP client:

`src/helpers/{library}/reference/resolve/resolvers/http-swagger-client/index.js`:
```javascript
Expand All @@ -221,7 +221,7 @@ class HTTPResolverSwaggerClient extends Resolver {
}

async resolve(uri) {
// Use swagger-js HTTP client with interceptors
// Use swagger-client HTTP client with interceptors
const response = await http({
url: uri,
timeout: this.timeout,
Expand All @@ -234,7 +234,7 @@ class HTTPResolverSwaggerClient extends Resolver {

**3.4 Implement Dereference Strategy**

Create custom dereference strategy with swagger-js specific behavior:
Create custom dereference strategy with swagger-client specific behavior:

`src/helpers/{library}/reference/dereference/strategies/openapi-X-Y-swagger-client/index.js`:
```javascript
Expand Down Expand Up @@ -981,7 +981,7 @@ Update project overview:
```markdown
## Project Overview

**swagger-js** supports:
**swagger-client** supports:
- OpenAPI X.Y.0 (latest)
- OpenAPI 3.1.0
- OpenAPI 3.0.x
Expand Down Expand Up @@ -1276,7 +1276,7 @@ Closes #ISSUE_NUMBER

### Resolution
- [x] New resolver strategy `openapi-X-Y-{library}`
- [x] Custom HTTP resolver using swagger-js HTTP client
- [x] Custom HTTP resolver using swagger-client HTTP client
- [x] OpenAPI X.Y specific JSON/YAML parsers
- [x] Custom dereference strategy
- [x] Normalization plugins
Expand Down Expand Up @@ -1520,7 +1520,7 @@ After the PR is merged:

- OpenAPI Specification: https://spec.openapis.org/
- ApiDOM Documentation: https://github.com/swagger-api/apidom
- SpecMap Library: Internal to swagger-js
- SpecMap Library: Internal to swagger-client
- Conventional Commits: https://www.conventionalcommits.org/

---
Expand All @@ -1539,4 +1539,4 @@ If you encounter any issues or have questions:

**Skill Version:** 1.0
**Last Updated:** 2026-01-23
**Maintained By:** swagger-js maintainers
**Maintained By:** swagger-client maintainers
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: npm test
env:
CI: true
- name: Build swagger-js
- name: Build swagger-client
run: npm run build
- name: Upload commonjs build artifacts
if: startsWith(matrix.node-version, '24')
Expand Down
8 changes: 4 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# CLAUDE.md - AI Assistant Guide for swagger-js
# CLAUDE.md - AI Assistant Guide for swagger-client

This document provides comprehensive guidance for AI assistants working on the swagger-js (swagger-client) codebase.
This document provides comprehensive guidance for AI assistants working on the swagger-client codebase.

## Project Overview

**swagger-js** (npm package: `swagger-client`) is a JavaScript module that allows you to fetch, resolve, and interact with Swagger/OpenAPI documents. It supports:
**swagger-client** is a JavaScript module that allows you to fetch, resolve, and interact with Swagger/OpenAPI documents. It supports:
- OpenAPI 3.2.0 (latest)
- OpenAPI 3.1.0
- OpenAPI 3.0.x (3.0.0 through 3.0.4)
Expand All @@ -18,7 +18,7 @@ The library is used by Swagger-UI and other tools in the OpenAPI ecosystem to pa
## Repository Structure

```
swagger-js/
swagger-client/
├── src/ # Source code (ES6+ modules)
│ ├── execute/ # Request execution logic for OAS operations
│ │ ├── oas3/ # OpenAPI 3.x execution
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
swagger-js/swagger-client
swagger-client
Copyright 2020-2021 SmartBear Software Inc.
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
# Swagger Client <img src="https://raw.githubusercontent.com/swagger-api/swagger.io/wordpress/images/assets/SW-logo-clr.png" height="50" align="right">

[![Build Status](https://github.com/swagger-api/swagger-js/actions/workflows/nodejs.yml/badge.svg)](https://github.com/swagger-api/swagger-js/actions)
[![Build Status](https://github.com/swagger-api/swagger-client/actions/workflows/nodejs.yml/badge.svg)](https://github.com/swagger-api/swagger-client/actions)

**Swagger Client** is a JavaScript module that allows you to fetch, resolve, and interact with Swagger/OpenAPI documents.

## New!

**This is the new version of swagger-js, 3.x.** The new version supports Swagger 2.0 as well as OpenAPI 3.
**This is the new version of Swagger Client, 3.x.** The new version supports Swagger 2.0 as well as OpenAPI 3.

Want to learn more? Check out our [FAQ](docs/migration/migration-2-x-to-3-x.md).

For features known to be missing from 3.x please see the [Graveyard](docs/migration/graveyard-3-x.md).


For the older version of swagger-js, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-js/tree/2.x).

> *The npm package is called `swagger-client` and the GitHub repository is `swagger-js`.
We'll be consolidating that soon. Just giving you the heads-up. You may see references to both names.*
For the older version of Swagger Client, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-client/tree/2.x).

## Compatibility
The OpenAPI Specification has undergone multiple revisions since initial creation in 2010.
Compatibility between Swagger Client and the OpenAPI Specification is as follows:

Swagger Client Version | Release Date | OpenAPI Spec compatibility | Notes
------------------ |--------------|---------------------------------------------------------| -----
3.37.x | 2026-02-27 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.1.0, 3.2.0 | [tag v3.37.0](https://github.com/swagger-api/swagger-js/releases/tag/v3.37.0)
3.33.x | 2024-12-30 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.1.0 | [tag v3.33.0](https://github.com/swagger-api/swagger-js/releases/tag/v3.33.0)
3.19.x | 2023-01-23 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0 | [tag v3.19.0-alpha.3](https://github.com/swagger-api/swagger-js/releases/tag/v3.19.0-alpha.3)
3.10.x | 2020-01-17 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3 | [tag v3.10.0](https://github.com/swagger-api/swagger-js/tree/v3.10.0)
2.1.32 | 2017-01-12 | 1.0, 1.1, 1.2 | [tag v2.1.32](https://github.com/swagger-api/swagger-js/tree/v2.1.32). This [release](https://github.com/swagger-api/swagger-js/releases/tag/v2.1.32) is only available on GitHub.
3.37.x | 2026-02-27 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.1.0, 3.2.0 | [tag v3.37.0](https://github.com/swagger-api/swagger-client/releases/tag/v3.37.0)
3.33.x | 2024-12-30 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.1.0 | [tag v3.33.0](https://github.com/swagger-api/swagger-client/releases/tag/v3.33.0)
3.19.x | 2023-01-23 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0 | [tag v3.19.0-alpha.3](https://github.com/swagger-api/swagger-client/releases/tag/v3.19.0-alpha.3)
3.10.x | 2020-01-17 | 2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3 | [tag v3.10.0](https://github.com/swagger-api/swagger-client/tree/v3.10.0)
2.1.32 | 2017-01-12 | 1.0, 1.1, 1.2 | [tag v2.1.32](https://github.com/swagger-api/swagger-client/tree/v2.1.32). This [release](https://github.com/swagger-api/swagger-client/releases/tag/v2.1.32) is only available on GitHub.

## Anonymized analytics

Expand Down
10 changes: 5 additions & 5 deletions docs/development/setting-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ If you use [nvm](https://github.com/nvm-sh/nvm), running following command insid

#### Setup steps

1. `git clone https://github.com/swagger-api/swagger-js.git`
2. `cd swagger-js`
1. `git clone https://github.com/swagger-api/swagger-client.git`
2. `cd swagger-client`
3. `npm install`
4. `npm run build`
5. `npm run test`
Expand All @@ -32,14 +32,14 @@ This section will guide you through how to do that.

You'll find complete information about how to do that in swagger-ui [Setting up documentation](https://github.com/swagger-api/swagger-ui/blob/main/docs/development/setting-up.md).

**2. Clone and install swagger-js repository**
**2. Clone and install swagger-client repository**
Comment thread
glowcloud marked this conversation as resolved.

You'll find complete information about how to do that in [Steps](setting-up.md#steps) section of this document.

**3. Link repositories using npm link**

```shell script
$ cd /path/to/swagger-js
$ cd /path/to/swagger-client
$ npm run build
$ npm link
$ cd /path/to/swagger-ui
Expand Down Expand Up @@ -68,7 +68,7 @@ in your favorite editor and return back the `"predev": "npm install"` script.
$ cd /path/to/swagger-ui
$ npm unlink --no-save swagger-client
$ npm install
$ cd /path/to/swagger-js
$ cd /path/to/swagger-client
$ npm unlink
```

Expand Down
2 changes: 1 addition & 1 deletion docs/migration/migration-2-x-to-3-x.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ client.clientAuthorizations.add('cookie', new CookieAuthorization('one=two'))
Currently you'd use...

> *__NOTE:__ We're working on changing this to be friendlier to use and to support the config file interface.*
> *See: https://github.com/swagger-api/swagger-js/issues/971*
> *See: https://github.com/swagger-api/swagger-client/issues/971*

```javascript
Swagger('http://petstore.swagger.io/v2/swagger.json', {
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/http-client-for-oas-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Property | Description
`pathName` | `String`. OpenAPI defines a unique operation as a combination of a path and an HTTP method. If `operationId` is not provided, this property must be set.
`method` | `String=["GET", "HEAD", "POST", "PUT", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH"]`. OpenAPI defines a unique operation as a combination of a path and an HTTP method. If `operationId` is not provided, this property must be set.
`parameters` | `Object`. Parameters object, eg: `{ q: 'search string' }`. Parameters not defined in `spec` will be ignored.
`parameterBuilders` | `Object=null`. When provided in shape of `{ body: Function, header: Function, query: Function, path: Function, formData: Function }`, it can fully conltrol how parameters of various types are built. This library comes with two default parameter builders: [OpenAPI 2.x builders](https://github.com/swagger-api/swagger-js/blob/main/src/execute/swagger2/parameter-builders.js) and [OpenAPI 3.0.x builders](https://github.com/swagger-api/swagger-js/blob/main/src/execute/oas3/parameter-builders.js).
`parameterBuilders` | `Object=null`. When provided in shape of `{ body: Function, header: Function, query: Function, path: Function, formData: Function }`, it can fully control how parameters of various types are built. This library comes with two default parameter builders: [OpenAPI 2.x builders](https://github.com/swagger-api/swagger-client/blob/main/src/execute/swagger2/parameter-builders.js) and [OpenAPI 3.0.x builders](https://github.com/swagger-api/swagger-client/blob/main/src/execute/oas3/parameter-builders.js).
`securities` | `Object`. Maps security schemes to a request. Securities not defined in `spec` will be ignored. <br/><br/>*Examples*<br /><br /> *Bearer:* `{ authorized: { BearerAuth: {value: "3492342948239482398"} } }` <br /><br /> *Basic:* `{ authorized: { BasicAuth: { username: 'login', password: 'secret' } } }` <br /><br /> *ApiKey:* `{ authorized: { ApiKey: { value: '234934239' } } }` <br /><br /> *oAuth2:* `{ authorized: { oAuth2: { token: { access_token: '234934239' } } } }`
`requestInterceptor` | `Function=identity`. Either synchronous or asynchronous function transformer that accepts `Request` and should return `Request`.
`responseInterceptor` | `Function=identity`. Either synchronous or asynchronous function transformer that accepts `Response` and should return `Response`.
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/tags-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Option | Description
`userFetch` | `Function=cross-fetch`. Custom **asynchronous** fetch function that accepts two arguments: the `url` and the `Request` object and must return a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
`skipNormalization` | `Boolean=false`. Normalization creates unique operationIds when explicit operationIds are duplicates, and preserve originals.

> *__Note:__ for more information about [requestInterceptor](http-client.md#request-interceptor), [responseInterceptor](http-client.md#response-interceptor) and [userFetch](https://github.com/swagger-api/swagger-js/blob/main/docs/usage/http-client.md#custom-fetch), please refer to the [HTTP Client](http-client.md) documentation.*
> *__Note:__ for more information about [requestInterceptor](http-client.md#request-interceptor), [responseInterceptor](http-client.md#response-interceptor) and [userFetch](https://github.com/swagger-api/swagger-client/blob/main/docs/usage/http-client.md#custom-fetch), please refer to the [HTTP Client](http-client.md) documentation.*

### Options override

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swagger-client",
"version": "3.38.0",
"description": "SwaggerJS - a collection of interfaces for OAI specs",
"description": "Swagger Client - a collection of interfaces for OAI specs",
"browser": {
"./src/helpers/btoa.node.js": "./src/helpers/btoa.browser.js",
"./lib/helpers/btoa.node.js": "./lib/helpers/btoa.browser.js",
Expand All @@ -14,7 +14,7 @@
"module": "es/index.js",
"jsnext:main": "es/index.js",
"unpkg": "dist/swagger-client.browser.min.js",
"repository": "git@github.com:swagger-api/swagger-js.git",
"repository": "git@github.com:swagger-api/swagger-client.git",
"contributors": [
"(in alphabetical order)",
"Anna Bodnia <anna.bodnia@gmail.com>",
Expand Down
24 changes: 12 additions & 12 deletions src/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export const self = {
};

// Make an execute, bound to arguments defined in mapTagOperation's callback (cb)
export function makeExecute(swaggerJs = {}) {
export function makeExecute(swaggerClient = {}) {
return ({ pathName, method, operationId }) =>
(parameters, opts = {}) => {
const { requestInterceptor, responseInterceptor, userFetch } = swaggerJs;
return swaggerJs.execute({
spec: swaggerJs.spec,
const { requestInterceptor, responseInterceptor, userFetch } = swaggerClient;
return swaggerClient.execute({
spec: swaggerClient.spec,
requestInterceptor,
responseInterceptor,
userFetch,
Expand All @@ -33,12 +33,12 @@ export function makeExecute(swaggerJs = {}) {
// The shape
// { apis: { [tag]: { operations: [operation]: { execute }}}}
// NOTE: this is mostly for compatibility
export function makeApisTagOperationsOperationExecute(swaggerJs = {}) {
export function makeApisTagOperationsOperationExecute(swaggerClient = {}) {
// { apis: tag: operations: execute }
const cb = self.makeExecute(swaggerJs);
const cb = self.makeExecute(swaggerClient);
const tagOperations = self.mapTagOperations({
v2OperationIdCompatibilityMode: swaggerJs.v2OperationIdCompatibilityMode,
spec: swaggerJs.spec,
v2OperationIdCompatibilityMode: swaggerClient.v2OperationIdCompatibilityMode,
spec: swaggerClient.spec,
cb,
});

Expand All @@ -58,12 +58,12 @@ export function makeApisTagOperationsOperationExecute(swaggerJs = {}) {
}

// .apis[tag][operationId]:ExecuteFunction interface
export function makeApisTagOperation(swaggerJs = {}) {
const cb = self.makeExecute(swaggerJs);
export function makeApisTagOperation(swaggerClient = {}) {
const cb = self.makeExecute(swaggerClient);
return {
apis: self.mapTagOperations({
v2OperationIdCompatibilityMode: swaggerJs.v2OperationIdCompatibilityMode,
spec: swaggerJs.spec,
v2OperationIdCompatibilityMode: swaggerClient.v2OperationIdCompatibilityMode,
spec: swaggerClient.spec,
cb,
}),
};
Expand Down
2 changes: 1 addition & 1 deletion test/bugs/1719.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/swagger-api/swagger-js/issues/1719
// https://github.com/swagger-api/swagger-client/issues/1719

import path from 'path';
import fs from 'fs';
Expand Down
10 changes: 5 additions & 5 deletions test/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('http', () => {
});

/**
* See https://github.com/swagger-api/swagger-js/issues/1005
* See https://github.com/swagger-api/swagger-client/issues/1005
*/
test.skip('should get a pet from the petstore', (done) => {
Swagger('http://localhost:8000/petstore.json').then((client) => {
Expand All @@ -168,7 +168,7 @@ describe('http', () => {
});

/**
* See https://github.com/swagger-api/swagger-js/issues/1277
* See https://github.com/swagger-api/swagger-client/issues/1277
*/
test('should return a helpful error when the connection is refused', () =>
Swagger('http://localhost:1/untouchable.yaml')
Expand All @@ -181,7 +181,7 @@ describe('http', () => {
}));

/**
* See https://github.com/swagger-api/swagger-js/issues/1002
* See https://github.com/swagger-api/swagger-client/issues/1002
*/
test.skip('should return an error when a spec doesnt exist', (done) => {
Swagger('http://localhost:8000/absent.yaml')
Expand All @@ -194,7 +194,7 @@ describe('http', () => {
});

/**
* See https://github.com/swagger-api/swagger-js/issues/1004
* See https://github.com/swagger-api/swagger-client/issues/1004
*/
test.skip('fail with invalid verbs', (done) => {
Swagger('http://localhost:8000/invalid-operation.yaml').then((client) => {
Expand All @@ -206,7 +206,7 @@ describe('http', () => {

/**
* Loads a spec where the `host` and `schema` are not defined
* See https://github.com/swagger-api/swagger-js/issues/1000
* See https://github.com/swagger-api/swagger-client/issues/1000
*/
test('use the host from whence the spec was fetched', (done) => {
Swagger('http://localhost:8000/pathless.yaml')
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/id-from-path-method/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('helpers', () => {
v2OperationIdCompatibilityMode: true,
});

// https://github.com/swagger-api/swagger-js/issues/1269#issue-309070070
// https://github.com/swagger-api/swagger-client/issues/1269#issue-309070070
expect(fn('/foo/{bar}/baz', 'get')).toEqual('get_foo_bar_baz');
expect(fn('/one/{foo}/{bar}', 'get')).toEqual('get_one_foo_bar');
expect(fn('/one/{bar}/-----{baz}', 'get')).toEqual('get_one_bar_baz');
Expand Down
2 changes: 1 addition & 1 deletion test/oas3/execute/build-request.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/swagger-api/swagger-js/issues/1116
// https://github.com/swagger-api/swagger-client/issues/1116
import { buildRequest } from '../../../src/execute/index.js';

describe('buildRequest - OAS 3.0.x', () => {
Expand Down