first commit

This commit is contained in:
2026-07-19 03:44:35 +09:00
commit 7f950339ae
23281 changed files with 3217138 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 James Messinger
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+122
View File
@@ -0,0 +1,122 @@
# Swagger 2.0 and OpenAPI 3.0 parser/validator
[![Build Status](https://github.com/APIDevTools/swagger-parser/workflows/CI-CD/badge.svg?branch=master)](https://github.com/APIDevTools/swagger-parser/actions)
[![Coverage Status](https://coveralls.io/repos/github/APIDevTools/swagger-parser/badge.svg?branch=master)](https://coveralls.io/github/APIDevTools/swagger-parser)
[![Tested on APIs.guru](https://api.apis.guru/badges/tested_on.svg)](https://apis.guru/browse-apis/)
[![npm](https://img.shields.io/npm/v/@apidevtools/swagger-parser.svg)](https://www.npmjs.com/package/@apidevtools/swagger-parser)
[![Dependencies](https://david-dm.org/APIDevTools/swagger-parser.svg)](https://david-dm.org/APIDevTools/swagger-parser)
[![License](https://img.shields.io/npm/l/@apidevtools/swagger-parser.svg)](LICENSE)
[![Buy us a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen)](https://shop.protect.earth/)
[![OS and Browser Compatibility](https://apidevtools.com/img/badges/ci-badges-with-ie.svg)](https://github.com/APIDevTools/swagger-parser/actions)
## Features
- Parses Swagger specs in **JSON** or **YAML** format
- Validates against the [Swagger 2.0 schema](https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v2.0/schema.json) or [OpenAPI 3.0 Schema](https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v3.0/schema.json)
- [Resolves](https://apidevtools.com/swagger-parser/docs/swagger-parser.html#resolveapi-options-callback) all `$ref` pointers, including external files and URLs
- Can [bundle](https://apidevtools.com/swagger-parser/docs/swagger-parser.html#bundleapi-options-callback) all your Swagger files into a single file that only has _internal_ `$ref` pointers
- Can [dereference](https://apidevtools.com/swagger-parser/docs/swagger-parser.html#dereferenceapi-options-callback) all `$ref` pointers, giving you a normal JavaScript object that's easy to work with
- **[Tested](https://github.com/APIDevTools/swagger-parser/actions)** in Node.js and all modern web browsers on Mac, Windows, and Linux
- Tested on **[over 1,500 real-world APIs](https://apis.guru/browse-apis/)** from Google, Microsoft, Facebook, Spotify, etc.
- Supports [circular references](https://apidevtools.com/swagger-parser/docs/#circular-refs), nested references, back-references, and cross-references
- Maintains object reference equality — `$ref` pointers to the same value always resolve to the same object instance
## Related Projects
- [Swagger CLI](https://github.com/APIDevTools/swagger-cli)
- [Swagger Express Middleware](https://github.com/APIDevTools/swagger-express-middleware)
## Example
```javascript
SwaggerParser.validate(myAPI, (err, api) => {
if (err) {
console.error(err);
} else {
console.log("API name: %s, Version: %s", api.info.title, api.info.version);
}
});
```
Or use `async`/`await` or [Promise](http://javascriptplayground.com/blog/2015/02/promises/) syntax instead. The following example is the same as above:
```javascript
try {
let api = await SwaggerParser.validate(myAPI);
console.log("API name: %s, Version: %s", api.info.title, api.info.version);
} catch (err) {
console.error(err);
}
```
For more detailed examples, please see the [API Documentation](https://apidevtools.com/swagger-parser/docs/)
## Installation
Install using [npm](https://docs.npmjs.com/about-npm/):
```bash
npm install @apidevtools/swagger-parser
```
## Usage
When using Swagger Parser in Node.js apps, you'll probably want to use **CommonJS** syntax:
```javascript
const SwaggerParser = require("@apidevtools/swagger-parser");
```
When using a transpiler such as [Babel](https://babeljs.io/) or [TypeScript](https://www.typescriptlang.org/), or a bundler such as [Webpack](https://webpack.js.org/) or [Rollup](https://rollupjs.org/), you can use **ECMAScript modules** syntax instead:
```javascript
import * as SwaggerParser from "@apidevtools/swagger-parser";
```
## Browser support
Swagger Parser supports recent versions of every major web browser. Older browsers may require [Babel](https://babeljs.io/) and/or [polyfills](https://babeljs.io/docs/en/next/babel-polyfill).
To use Swagger Parser in a browser, you'll need to use a bundling tool such as [Webpack](https://webpack.js.org/), [Rollup](https://rollupjs.org/), [Parcel](https://parceljs.org/), or [Browserify](http://browserify.org/). Some bundlers may require a bit of configuration, such as setting `browser: true` in [rollup-plugin-resolve](https://github.com/rollup/rollup-plugin-node-resolve).
## API Documentation
Full API documentation is available [right here](https://apidevtools.com/swagger-parser/docs/)
## Security
The library, by default, attempts to resolve any files referenced using `$ref`, without considering file extensions or the location of the files. This can result in Local File Inclusion (LFI), thus, potentially sensitive information disclosure. Developers must be cautious when working with documents from untrusted sources. See [here](SECURITY.md) for more details and information on how to mitigate LFI.
## Contributing
I welcome any contributions, enhancements, and bug-fixes. [Open an issue](https://github.com/APIDevTools/swagger-parser/issues) on GitHub and [submit a pull request](https://github.com/APIDevTools/swagger-parser/pulls).
To test the project locally on your computer:
1. **Clone this repo**<br>
`git clone https://github.com/APIDevTools/swagger-parser.git`
2. **Install dependencies**<br>
`npm install`
3. **Run the tests**<br>
`npm test`
4. **Check the code coverage**<br>
`npm run coverage`
## License
Swagger Parser is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.
This package is [Treeware](http://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://shop.protect.earth) to thank us for our work.
## Big Thanks To
Thanks to these awesome companies for their support of Open Source developers ❤
[![GitHub](https://apidevtools.com/img/badges/github.svg)](https://github.com/open-source)
[![NPM](https://apidevtools.com/img/badges/npm.svg)](https://www.npmjs.com/)
[![Coveralls](https://apidevtools.com/img/badges/coveralls.svg)](https://coveralls.io)
+363
View File
@@ -0,0 +1,363 @@
import type { OpenAPI } from "openapi-types";
import type {
HTTPResolverOptions,
ResolverOptions,
ParserOptions,
FileInfo,
$Refs,
} from "@apidevtools/json-schema-ref-parser";
export = SwaggerParser;
/**
* This is the default export of Swagger Parser. You can creates instances of this class using new SwaggerParser(), or you can just call its static methods.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html
*/
declare class SwaggerParser {
/**
* The `api` property is the parsed/bundled/dereferenced OpenAPI definition. This is the same value that is passed to the callback function (or Promise) when calling the parse, bundle, or dereference methods.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#api
*/
public api: OpenAPI.Document;
/**
* The $refs property is a `$Refs` object, which lets you access all of the externally-referenced files in the OpenAPI definition, as well as easily get and set specific values in the OpenAPI definition using JSON pointers.
*
* This is the same value that is passed to the callback function (or Promise) when calling the `resolve` method.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#refs
*/
public $refs: $Refs;
/**
* Parses, dereferences, and validates the given Swagger API.
* Depending on the options, validation can include JSON Schema validation and/or Swagger Spec validation.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#validateapi-options-callback
*
* @param api An OpenAPI definition, or the file path or URL of an OpenAPI definition. See the `parse` method for more info.
* @param options (optional)
* @param callback (optional) A callback that will receive the dereferenced OpenAPI definition
*/
public validate(api: string | OpenAPI.Document, callback: SwaggerParser.ApiCallback): void;
public validate(
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public validate(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public validate(api: string | OpenAPI.Document): Promise<OpenAPI.Document>;
public validate(api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<OpenAPI.Document>;
public validate(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
): Promise<OpenAPI.Document>;
/**
* Parses, dereferences, and validates the given Swagger API.
* Depending on the options, validation can include JSON Schema validation and/or Swagger Spec validation.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#validateapi-options-callback
*
* @param api An OpenAPI definition, or the file path or URL of an OpenAPI definition. See the `parse` method for more info.
* @param options (optional)
* @param callback (optional) A callback that will receive the dereferenced OpenAPI definition
*/
public static validate(api: string | OpenAPI.Document, callback: SwaggerParser.ApiCallback): void;
public static validate(
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public static validate(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public static validate(api: string | OpenAPI.Document): Promise<OpenAPI.Document>;
public static validate(api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<OpenAPI.Document>;
public static validate(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
): Promise<OpenAPI.Document>;
/**
* Dereferences all `$ref` pointers in the OpenAPI definition, replacing each reference with its resolved value. This results in an API definition that does not contain any `$ref` pointers. Instead, it's a normal JavaScript object tree that can easily be crawled and used just like any other JavaScript object. This is great for programmatic usage, especially when using tools that don't understand JSON references.
*
* The dereference method maintains object reference equality, meaning that all `$ref` pointers that point to the same object will be replaced with references to the same object. Again, this is great for programmatic usage, but it does introduce the risk of circular references, so be careful if you intend to serialize the API definition using `JSON.stringify()`. Consider using the bundle method instead, which does not create circular references.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#dereferenceapi-options-callback
*
* @param api An OpenAPI definition, or the file path or URL of an OpenAPI definition. See the `parse` method for more info.
* @param options (optional)
* @param callback (optional) A callback that will receive the dereferenced OpenAPI definition
*/
public dereference(api: string | OpenAPI.Document, callback: SwaggerParser.ApiCallback): void;
public dereference(
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public dereference(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public dereference(api: string | OpenAPI.Document): Promise<OpenAPI.Document>;
public dereference(api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<OpenAPI.Document>;
public dereference(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
): Promise<OpenAPI.Document>;
/**
* Dereferences all `$ref` pointers in the OpenAPI definition, replacing each reference with its resolved value. This results in an API definition that does not contain any `$ref` pointers. Instead, it's a normal JavaScript object tree that can easily be crawled and used just like any other JavaScript object. This is great for programmatic usage, especially when using tools that don't understand JSON references.
*
* The dereference method maintains object reference equality, meaning that all `$ref` pointers that point to the same object will be replaced with references to the same object. Again, this is great for programmatic usage, but it does introduce the risk of circular references, so be careful if you intend to serialize the API definition using `JSON.stringify()`. Consider using the bundle method instead, which does not create circular references.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#dereferenceapi-options-callback
*
* @param api An OpenAPI definition, or the file path or URL of an OpenAPI definition. See the `parse` method for more info.
* @param options (optional)
* @param callback (optional) A callback that will receive the dereferenced OpenAPI definition
*/
public static dereference(api: string | OpenAPI.Document, callback: SwaggerParser.ApiCallback): void;
public static dereference(
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public static dereference(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public static dereference(api: string | OpenAPI.Document): Promise<OpenAPI.Document>;
public static dereference(api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<OpenAPI.Document>;
public static dereference(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
): Promise<OpenAPI.Document>;
/**
* Bundles all referenced files/URLs into a single API definition that only has internal `$ref` pointers. This lets you split-up your API definition however you want while you're building it, but easily combine all those files together when it's time to package or distribute the API definition to other people. The resulting API definition size will be small, since it will still contain internal JSON references rather than being fully-dereferenced.
*
* This also eliminates the risk of circular references, so the API definition can be safely serialized using `JSON.stringify()`.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#bundleapi-options-callback
*
* @param api An OpenAPI definition, or the file path or URL of an OpenAPI definition. See the `parse` method for more info.
* @param options (optional)
* @param callback (optional) A callback that will receive the bundled API definition object
*/
public bundle(api: string | OpenAPI.Document, callback: SwaggerParser.ApiCallback): void;
public bundle(
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public bundle(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public bundle(api: string | OpenAPI.Document): Promise<OpenAPI.Document>;
public bundle(api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<OpenAPI.Document>;
public bundle(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
): Promise<OpenAPI.Document>;
/**
* Bundles all referenced files/URLs into a single API definition that only has internal `$ref` pointers. This lets you split-up your API definition however you want while you're building it, but easily combine all those files together when it's time to package or distribute the API definition to other people. The resulting API definition size will be small, since it will still contain internal JSON references rather than being fully-dereferenced.
*
* This also eliminates the risk of circular references, so the API definition can be safely serialized using `JSON.stringify()`.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#bundleapi-options-callback
*
* @param api An OpenAPI definition, or the file path or URL of an OpenAPI definition. See the `parse` method for more info.
* @param options (optional)
* @param callback (optional) A callback that will receive the bundled API definition object
*/
public static bundle(api: string | OpenAPI.Document, callback: SwaggerParser.ApiCallback): void;
public static bundle(
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public static bundle(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public static bundle(api: string | OpenAPI.Document): Promise<OpenAPI.Document>;
public static bundle(api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<OpenAPI.Document>;
public static bundle(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
): Promise<OpenAPI.Document>;
/**
* *This method is used internally by other methods, such as `bundle` and `dereference`. You probably won't need to call this method yourself.*
*
* Parses the given OpenAPI definition file (in JSON or YAML format), and returns it as a JavaScript object. This method `does not` resolve `$ref` pointers or dereference anything. It simply parses one file and returns it.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#parseapi-options-callback
*
* @param api An OpenAPI definition, or the file path or URL of an OpenAPI definition. The path can be absolute or relative. In Node, the path is relative to `process.cwd()`. In the browser, it's relative to the URL of the page.
* @param options (optional)
* @param callback (optional) A callback that will receive the parsed OpenAPI definition object, or an error
*/
public parse(api: string | OpenAPI.Document, callback: SwaggerParser.ApiCallback): void;
public parse(
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public parse(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public parse(api: string | OpenAPI.Document): Promise<OpenAPI.Document>;
public parse(api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<OpenAPI.Document>;
public parse(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
): Promise<OpenAPI.Document>;
/**
* *This method is used internally by other methods, such as `bundle` and `dereference`. You probably won't need to call this method yourself.*
*
* Parses the given OpenAPI definition file (in JSON or YAML format), and returns it as a JavaScript object. This method `does not` resolve `$ref` pointers or dereference anything. It simply parses one file and returns it.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#parseapi-options-callback
*
* @param api An OpenAPI definition, or the file path or URL of an OpenAPI definition. The path can be absolute or relative. In Node, the path is relative to `process.cwd()`. In the browser, it's relative to the URL of the page.
* @param options (optional)
* @param callback (optional) A callback that will receive the parsed OpenAPI definition object, or an error
*/
public static parse(api: string | OpenAPI.Document, callback: SwaggerParser.ApiCallback): void;
public static parse(
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public static parse(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.ApiCallback,
): void;
public static parse(api: string | OpenAPI.Document): Promise<OpenAPI.Document>;
public static parse(api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<OpenAPI.Document>;
public static parse(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
): Promise<OpenAPI.Document>;
/**
* *This method is used internally by other methods, such as `bundle` and `dereference`. You probably won't need to call this method yourself.*
*
* Resolves all JSON references (`$ref` pointers) in the given OpenAPI definition file. If it references any other files/URLs, then they will be downloaded and resolved as well. This method **does not** dereference anything. It simply gives you a `$Refs` object, which is a map of all the resolved references and their values.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#resolveapi-options-callback
*
* @param api An OpenAPI definition, or the file path or URL of an OpenAPI definition. See the `parse` method for more info.
* @param options (optional)
* @param callback (optional) A callback that will receive a `$Refs` object
*/
public resolve(api: string | OpenAPI.Document, callback: SwaggerParser.$RefsCallback): void;
public resolve(
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.$RefsCallback,
): void;
public resolve(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.$RefsCallback,
): void;
public resolve(api: string | OpenAPI.Document): Promise<$Refs>;
public resolve(api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<$Refs>;
public resolve(baseUrl: string, api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<$Refs>;
/**
* *This method is used internally by other methods, such as `bundle` and `dereference`. You probably won't need to call this method yourself.*
*
* Resolves all JSON references (`$ref` pointers) in the given OpenAPI definition file. If it references any other files/URLs, then they will be downloaded and resolved as well. This method **does not** dereference anything. It simply gives you a `$Refs` object, which is a map of all the resolved references and their values.
*
* See https://apitools.dev/swagger-parser/docs/swagger-parser.html#resolveapi-options-callback
*
* @param api An OpenAPI definition, or the file path or URL of an OpenAPI definition. See the `parse` method for more info.
* @param options (optional)
* @param callback (optional) A callback that will receive a `$Refs` object
*/
public static resolve(api: string | OpenAPI.Document, callback: SwaggerParser.$RefsCallback): void;
public static resolve(
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.$RefsCallback,
): void;
public static resolve(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
callback: SwaggerParser.$RefsCallback,
): void;
public static resolve(api: string | OpenAPI.Document): Promise<$Refs>;
public static resolve(api: string | OpenAPI.Document, options: SwaggerParser.Options): Promise<$Refs>;
public static resolve(
baseUrl: string,
api: string | OpenAPI.Document,
options: SwaggerParser.Options,
): Promise<$Refs>;
}
declare namespace SwaggerParser {
export type ApiCallback = (err: Error | null, api?: OpenAPI.Document) => any;
export type $RefsCallback = (err: Error | null, $refs?: $Refs) => any;
/**
* See https://apitools.dev/swagger-parser/docs/options.html
*/
export interface Options extends Partial<ParserOptions> {
/**
* The `validate` options control how Swagger Parser will validate the API.
*/
validate?: {
/**
* If set to `false`, then validating against the Swagger 2.0 Schema or OpenAPI 3.0 Schema is disabled.
*/
schema?: boolean;
/**
* If set to `false`, then validating against the Swagger 2.0 Specification is disabled.
*/
spec?: boolean;
};
}
export { HTTPResolverOptions, ResolverOptions, ParserOptions, FileInfo };
}
+186
View File
@@ -0,0 +1,186 @@
"use strict";
const validateSchema = require("./validators/schema");
const validateSpec = require("./validators/spec");
const {
jsonSchemaParserNormalizeArgs: normalizeArgs,
dereferenceInternal: dereference,
$RefParser,
} = require("@apidevtools/json-schema-ref-parser");
const util = require("./util");
const Options = require("./options");
const maybe = require("call-me-maybe");
const supported31Versions = ["3.1.0", "3.1.1", "3.1.2"];
const supported30Versions = ["3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4"];
const supportedVersions = [...supported31Versions, ...supported30Versions];
/**
* This class parses a Swagger 2.0 or 3.0 API, resolves its JSON references and their resolved values,
* and provides methods for traversing, dereferencing, and validating the API.
*
* @class
* @augments $RefParser
*/
class SwaggerParser extends $RefParser {
/**
* Parses the given Swagger API.
* This method does not resolve any JSON references.
* It just reads a single file in JSON or YAML format, and parse it as a JavaScript object.
*
* @param {string} [path] - The file path or URL of the JSON schema
* @param {object} [api] - The Swagger API object. This object will be used instead of reading from `path`.
* @param {ParserOptions} [options] - Options that determine how the API is parsed
* @param {Function} [callback] - An error-first callback. The second parameter is the parsed API object.
* @returns {Promise} - The returned promise resolves with the parsed API object.
*/
async parse(path, api, options, callback) {
let args = normalizeArgs(arguments);
args.options = new Options(args.options);
try {
let schema = await super.parse(args.path, args.schema, args.options);
if (schema.swagger) {
if (typeof schema.swagger === "number") {
// This is a very common mistake, so give a helpful error message
throw new SyntaxError('Swagger version number must be a string (e.g. "2.0") not a number.');
} else if (schema.info && typeof schema.info.version === "number") {
// This is a very common mistake, so give a helpful error message
throw new SyntaxError('API version number must be a string (e.g. "1.0.0") not a number.');
} else if (schema.swagger !== "2.0") {
throw new SyntaxError(`Unrecognized Swagger version: ${schema.swagger}. Expected 2.0`);
}
} else {
if (schema.paths === undefined) {
if (supported31Versions.indexOf(schema.openapi) !== -1) {
if (schema.webhooks === undefined) {
throw new SyntaxError(`${args.path || args.schema} is not a valid Openapi API definition`);
}
} else {
throw new SyntaxError(`${args.path || args.schema} is not a valid Openapi API definition`);
}
} else if (typeof schema.openapi === "number") {
// This is a very common mistake, so give a helpful error message
throw new SyntaxError('Openapi version number must be a string (e.g. "3.0.0") not a number.');
} else if (schema.info && typeof schema.info.version === "number") {
// This is a very common mistake, so give a helpful error message
throw new SyntaxError('API version number must be a string (e.g. "1.0.0") not a number.');
} else if (supportedVersions.indexOf(schema.openapi) === -1) {
throw new SyntaxError(
`Unsupported OpenAPI version: ${schema.openapi}. ` +
`Swagger Parser only supports versions ${supportedVersions.join(", ")}`,
);
}
// This is an OpenAPI v3 schema, check if the "servers" have any relative paths and
// fix them if the content was pulled from a web resource
util.fixOasRelativeServers(schema, args.path);
}
// Looks good!
return maybe(args.callback, Promise.resolve(schema));
} catch (err) {
return maybe(args.callback, Promise.reject(err));
}
}
/**
* Parses, dereferences, and validates the given Swagger API.
* Depending on the options, validation can include JSON Schema validation and/or Swagger Spec validation.
*
* @param {string} [path] - The file path or URL of the JSON schema
* @param {object} [api] - The Swagger API object. This object will be used instead of reading from `path`.
* @param {ParserOptions} [options] - Options that determine how the API is parsed, dereferenced, and validated
* @param {Function} [callback] - An error-first callback. The second parameter is the parsed API object.
* @returns {Promise} - The returned promise resolves with the parsed API object.
*/
async validate(path, api, options, callback) {
let me = this;
let args = normalizeArgs(arguments);
args.options = new Options(args.options);
// ZSchema doesn't support circular objects, so don't dereference circular $refs yet
// (see https://github.com/zaggino/z-schema/issues/137)
let circular$RefOption = args.options.dereference.circular;
args.options.validate.schema && (args.options.dereference.circular = "ignore");
try {
await this.dereference(args.path, args.schema, args.options);
// Restore the original options, now that we're done dereferencing
args.options.dereference.circular = circular$RefOption;
if (args.options.validate.schema) {
// Validate the API against the Swagger schema
// NOTE: This is safe to do, because we haven't dereferenced circular $refs yet
validateSchema(me.api);
if (me.$refs.circular) {
if (circular$RefOption === true) {
// The API has circular references,
// so we need to do a second-pass to fully-dereference it
dereference(me, args.options);
} else if (circular$RefOption === false) {
// The API has circular references, and they're not allowed, so throw an error
throw new ReferenceError("The API contains circular references");
}
}
}
if (args.options.validate.spec) {
// Validate the API against the Swagger spec
validateSpec(me.api);
}
return maybe(args.callback, Promise.resolve(me.schema));
} catch (err) {
return maybe(args.callback, Promise.reject(err));
}
}
}
/**
* Alias {@link $RefParser#schema} as {@link SwaggerParser#api}
*/
Object.defineProperty(SwaggerParser.prototype, "api", {
configurable: true,
enumerable: true,
get() {
return this.schema;
},
});
/**
* The Swagger object
* https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object
*
* @typedef {{swagger: string, info: {}, paths: {}}} SwaggerObject
*/
const defaultExport = SwaggerParser;
defaultExport.validate = (...args) => {
const defaultInstance = new SwaggerParser();
return defaultInstance.validate(...args);
};
defaultExport.dereference = (...args) => {
const defaultInstance = new SwaggerParser();
return defaultInstance.dereference(...args);
};
defaultExport.bundle = (...args) => {
const defaultInstance = new SwaggerParser();
return defaultInstance.bundle(...args);
};
defaultExport.parse = (...args) => {
const defaultInstance = new SwaggerParser();
return defaultInstance.parse(...args);
};
defaultExport.resolve = (...args) => {
const defaultInstance = new SwaggerParser();
return defaultInstance.resolve(...args);
};
defaultExport.default = defaultExport;
defaultExport.SwaggerParser = defaultExport;
module.exports = defaultExport;
+71
View File
@@ -0,0 +1,71 @@
"use strict";
const { getJsonSchemaRefParserDefaultOptions } = require("@apidevtools/json-schema-ref-parser");
const schemaValidator = require("./validators/schema");
const specValidator = require("./validators/spec");
module.exports = ParserOptions;
/**
* Merges the properties of the source object into the target object.
*
* @param target - The object that we're populating
* @param source - The options that are being merged
* @returns
*/
function merge(target, source) {
if (isMergeable(source)) {
// prevent prototype pollution
const keys = Object.keys(source).filter((key) => !["__proto__", "constructor", "prototype"].includes(key));
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const sourceSetting = source[key];
const targetSetting = target[key];
if (isMergeable(sourceSetting)) {
// It's a nested object, so merge it recursively
target[key] = merge(targetSetting || {}, sourceSetting);
} else if (sourceSetting !== undefined) {
// It's a scalar value, function, or array. No merging necessary. Just overwrite the target value.
target[key] = sourceSetting;
}
}
}
return target;
}
/**
* Determines whether the given value can be merged,
* or if it is a scalar value that should just override the target value.
*
* @param val
* @returns
*/
function isMergeable(val) {
return val && typeof val === "object" && !Array.isArray(val) && !(val instanceof RegExp) && !(val instanceof Date);
}
/**
* Options that determine how Swagger APIs are parsed, resolved, dereferenced, and validated.
*
* @param {object|ParserOptions} [_options] - Overridden options
* @class
* @augments $RefParserOptions
*/
function ParserOptions(_options) {
const defaultOptions = getJsonSchemaRefParserDefaultOptions();
const options = merge(defaultOptions, ParserOptions.defaults);
return merge(options, _options);
}
ParserOptions.defaults = {
/**
* Determines how the API definition will be validated.
*
* You can add additional validators of your own, replace an existing one with
* your own implemenation, or disable any validator by setting it to false.
*/
validate: {
schema: schemaValidator,
spec: specValidator,
},
};
+77
View File
@@ -0,0 +1,77 @@
"use strict";
const util = require("util");
exports.format = util.format;
exports.inherits = util.inherits;
const parse = (u) => new URL(u);
/**
* Regular Expression that matches Swagger path params.
*/
exports.swaggerParamRegExp = /\{([^/}]+)}/g;
/**
* List of HTTP verbs used for OperationItem as per the Swagger specification
*/
const operationsList = ["get", "post", "put", "delete", "patch", "options", "head", "trace"];
/**
* This function takes in a Server object, checks if it has relative path
* and then fixes it as per the path url
*
* @param {object} server - The server object to be fixed
* @param {string} path - The path (an http/https url) from where the file was downloaded
* @returns {object} - The fixed server object
*/
function fixServers(server, path) {
// Server url starting with "/" tells that it is not an http(s) url
if (server.url && server.url.startsWith("/")) {
const inUrl = parse(path);
const finalUrl = inUrl.protocol + "//" + inUrl.hostname + server.url;
server.url = finalUrl;
return server;
}
}
/**
* This function helps fix the relative servers in the API definition file
* be at root, path or operation's level
*/
function fixOasRelativeServers(schema, filePath) {
if (schema.openapi && filePath && (filePath.startsWith("http:") || filePath.startsWith("https:"))) {
/**
* From OpenAPI v3 spec for Server object's url property: "REQUIRED. A URL to the target host.
* This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where
* the OpenAPI document is being served."
* Further, the spec says that "servers" property can show up at root level, in 'Path Item' object or in 'Operation' object.
* However, interpretation of the spec says that relative paths for servers should take into account the hostname that
* serves the OpenAPI file.
*/
if (schema.servers) {
schema.servers.map((server) => fixServers(server, filePath)); // Root level servers array's fixup
}
// Path, Operation, or Webhook level servers array's fixup
["paths", "webhooks"].forEach((component) => {
Object.keys(schema[component] || []).forEach((path) => {
const pathItem = schema[component][path];
Object.keys(pathItem).forEach((opItem) => {
if (opItem === "servers") {
// servers at pathitem level
pathItem[opItem].map((server) => fixServers(server, filePath));
} else if (operationsList.includes(opItem)) {
// servers at operation level
if (pathItem[opItem].servers) {
pathItem[opItem].servers.map((server) => fixServers(server, filePath));
}
}
});
});
});
} else {
// Do nothing and return
}
}
exports.fixOasRelativeServers = fixOasRelativeServers;
@@ -0,0 +1,92 @@
"use strict";
const util = require("../util");
const Ajv = require("ajv/dist/2020");
const { openapi } = require("@apidevtools/openapi-schemas");
module.exports = validateSchema;
/**
* Validates the given Swagger API against the Swagger 2.0 or OpenAPI 3.0 and 3.1 schemas.
*
* @param {SwaggerObject} api
*/
function validateSchema(api) {
let ajv;
// Choose the appropriate schema (Swagger or OpenAPI)
let schema;
if (api.swagger) {
schema = openapi.v2;
ajv = initializeAjv();
} else {
if (api.openapi.startsWith("3.1")) {
schema = openapi.v31;
// There's a bug with Ajv in how it handles `$dynamicRef` in the way that it's used within the 3.1 schema so we
// need to do some adhoc workarounds.
// https://github.com/OAI/OpenAPI-Specification/issues/2689
// https://github.com/ajv-validator/ajv/issues/1573
const schemaDynamicRef = schema.$defs.schema;
delete schemaDynamicRef.$dynamicAnchor;
schema.$defs.components.properties.schemas.additionalProperties = schemaDynamicRef;
schema.$defs.header.dependentSchemas.schema.properties.schema = schemaDynamicRef;
schema.$defs["media-type"].properties.schema = schemaDynamicRef;
schema.$defs.parameter.properties.schema = schemaDynamicRef;
ajv = initializeAjv(false);
} else {
schema = openapi.v3;
ajv = initializeAjv();
}
}
// Validate against the schema
let isValid = ajv.validate(schema, api);
if (!isValid) {
let err = ajv.errors;
let message = "Swagger schema validation failed.\n" + formatAjvError(err);
const error = new SyntaxError(message);
error.details = err;
throw error;
}
}
/**
* Determines which version of Ajv to load and prepares it for use.
*
* @param {bool} draft04
* @returns {Ajv}
*/
function initializeAjv(draft04 = true) {
const opts = {
allErrors: true,
strict: false,
validateFormats: false,
};
if (draft04) {
const AjvDraft4 = require("ajv-draft-04");
return new AjvDraft4(opts);
}
return new Ajv(opts);
}
/**
* Run through a set of Ajv errors and compile them into an error message string.
*
* @param {object[]} errors - The Ajv errors
* @param {string} [indent] - The whitespace used to indent the error message
* @returns {string}
*/
function formatAjvError(errors, indent) {
indent = indent || " ";
let message = "";
for (let error of errors) {
message += util.format(`${indent}#${error.instancePath.length ? error.instancePath : "/"} ${error.message}\n`);
}
return message;
}
+352
View File
@@ -0,0 +1,352 @@
"use strict";
const util = require("../util");
const swaggerMethods = require("@apidevtools/swagger-methods");
const primitiveTypes = ["array", "boolean", "integer", "number", "string"];
const schemaTypes = ["array", "boolean", "integer", "number", "string", "object", "null", undefined];
module.exports = validateSpec;
/**
* Validates parts of the Swagger 2.0 spec that aren't covered by the Swagger 2.0 JSON Schema.
*
* @param {SwaggerObject} api
*/
function validateSpec(api) {
if (api.openapi) {
// We don't (yet) support validating against the OpenAPI spec
return;
}
let paths = Object.keys(api.paths || {});
let operationIds = [];
for (let pathName of paths) {
let path = api.paths[pathName];
let pathId = "/paths" + pathName;
if (path && pathName.indexOf("/") === 0) {
validatePath(api, path, pathId, operationIds);
}
}
let definitions = Object.keys(api.definitions || {});
for (let definitionName of definitions) {
let definition = api.definitions[definitionName];
let definitionId = "/definitions/" + definitionName;
validateRequiredPropertiesExist(definition, definitionId);
}
}
/**
* Validates the given path.
*
* @param {SwaggerObject} api - The entire Swagger API object
* @param {object} path - A Path object, from the Swagger API
* @param {string} pathId - A value that uniquely identifies the path
* @param {string} operationIds - An array of collected operationIds found in other paths
*/
function validatePath(api, path, pathId, operationIds) {
for (let operationName of swaggerMethods) {
let operation = path[operationName];
let operationId = pathId + "/" + operationName;
if (operation) {
let declaredOperationId = operation.operationId;
if (declaredOperationId) {
if (operationIds.indexOf(declaredOperationId) === -1) {
operationIds.push(declaredOperationId);
} else {
throw new SyntaxError(`Validation failed. Duplicate operation id '${declaredOperationId}'`);
}
}
validateParameters(api, path, pathId, operation, operationId);
let responses = Object.keys(operation.responses || {});
for (let responseName of responses) {
let response = operation.responses[responseName];
let responseId = operationId + "/responses/" + responseName;
validateResponse(responseName, response || {}, responseId);
}
}
}
}
/**
* Validates the parameters for the given operation.
*
* @param {SwaggerObject} api - The entire Swagger API object
* @param {object} path - A Path object, from the Swagger API
* @param {string} pathId - A value that uniquely identifies the path
* @param {object} operation - An Operation object, from the Swagger API
* @param {string} operationId - A value that uniquely identifies the operation
*/
function validateParameters(api, path, pathId, operation, operationId) {
let pathParams = path.parameters || [];
let operationParams = operation.parameters || [];
// Check for duplicate path parameters
try {
checkForDuplicates(pathParams);
} catch (e) {
throw new SyntaxError(e, `Validation failed. ${pathId} has duplicate parameters`);
}
// Check for duplicate operation parameters
try {
checkForDuplicates(operationParams);
} catch (e) {
throw new SyntaxError(e, `Validation failed. ${operationId} has duplicate parameters`);
}
// Combine the path and operation parameters,
// with the operation params taking precedence over the path params
let params = pathParams.reduce((combinedParams, value) => {
let duplicate = combinedParams.some((param) => {
return param.in === value.in && param.name === value.name;
});
if (!duplicate) {
combinedParams.push(value);
}
return combinedParams;
}, operationParams.slice());
validateBodyParameters(params, operationId);
validatePathParameters(params, pathId, operationId);
validateParameterTypes(params, api, operation, operationId);
}
/**
* Validates body and formData parameters for the given operation.
*
* @param {object[]} params - An array of Parameter objects
* @param {string} operationId - A value that uniquely identifies the operation
*/
function validateBodyParameters(params, operationId) {
let bodyParams = params.filter((param) => {
return param.in === "body";
});
let formParams = params.filter((param) => {
return param.in === "formData";
});
// There can only be one "body" parameter
if (bodyParams.length > 1) {
throw new SyntaxError(
`Validation failed. ${operationId} has ${bodyParams.length} body parameters. Only one is allowed.`,
);
} else if (bodyParams.length > 0 && formParams.length > 0) {
// "body" params and "formData" params are mutually exclusive
throw new SyntaxError(
`Validation failed. ${operationId} has body parameters and formData parameters. Only one or the other is allowed.`,
);
}
}
/**
* Validates path parameters for the given path.
*
* @param {object[]} params - An array of Parameter objects
* @param {string} pathId - A value that uniquely identifies the path
* @param {string} operationId - A value that uniquely identifies the operation
*/
function validatePathParameters(params, pathId, operationId) {
// Find all {placeholders} in the path string
let placeholders = pathId.match(util.swaggerParamRegExp) || [];
// Check for duplicates
for (let i = 0; i < placeholders.length; i++) {
for (let j = i + 1; j < placeholders.length; j++) {
if (placeholders[i] === placeholders[j]) {
throw new SyntaxError(
`Validation failed. ${operationId} has multiple path placeholders named ${placeholders[i]}`,
);
}
}
}
params = params.filter((param) => {
return param.in === "path";
});
for (let param of params) {
if (param.required !== true) {
throw new SyntaxError(
"Validation failed. Path parameters cannot be optional. " +
`Set required=true for the "${param.name}" parameter at ${operationId}`,
);
}
let match = placeholders.indexOf("{" + param.name + "}");
if (match === -1) {
throw new SyntaxError(
`Validation failed. ${operationId} has a path parameter named "${param.name}", ` +
`but there is no corresponding {${param.name}} in the path string`,
);
}
placeholders.splice(match, 1);
}
if (placeholders.length > 0) {
throw new SyntaxError(`Validation failed. ${operationId} is missing path parameter(s) for ${placeholders}`);
}
}
/**
* Validates data types of parameters for the given operation.
*
* @param {object[]} params - An array of Parameter objects
* @param {object} api - The entire Swagger API object
* @param {object} operation - An Operation object, from the Swagger API
* @param {string} operationId - A value that uniquely identifies the operation
*/
function validateParameterTypes(params, api, operation, operationId) {
for (let param of params) {
let parameterId = operationId + "/parameters/" + param.name;
let schema, validTypes;
switch (param.in) {
case "body":
schema = param.schema;
validTypes = schemaTypes;
break;
case "formData":
schema = param;
validTypes = primitiveTypes.concat("file");
break;
default:
schema = param;
validTypes = primitiveTypes;
}
validateSchema(schema, parameterId, validTypes);
validateRequiredPropertiesExist(schema, parameterId);
if (schema.type === "file") {
// "file" params must consume at least one of these MIME types
let formData = /multipart\/(.*\+)?form-data/;
let urlEncoded = /application\/(.*\+)?x-www-form-urlencoded/;
let consumes = operation.consumes || api.consumes || [];
let hasValidMimeType = consumes.some((consume) => {
return formData.test(consume) || urlEncoded.test(consume);
});
if (!hasValidMimeType) {
throw new SyntaxError(
`Validation failed. ${operationId} has a file parameter, so it must consume multipart/form-data ` +
"or application/x-www-form-urlencoded",
);
}
}
}
}
/**
* Checks the given parameter list for duplicates, and throws an error if found.
*
* @param {object[]} params - An array of Parameter objects
*/
function checkForDuplicates(params) {
for (let i = 0; i < params.length - 1; i++) {
let outer = params[i];
for (let j = i + 1; j < params.length; j++) {
let inner = params[j];
if (outer.name === inner.name && outer.in === inner.in) {
throw new SyntaxError(`Validation failed. Found multiple ${outer.in} parameters named "${outer.name}"`);
}
}
}
}
/**
* Validates the given response object.
*
* @param {string} code - The HTTP response code (or "default")
* @param {object} response - A Response object, from the Swagger API
* @param {string} responseId - A value that uniquely identifies the response
*/
function validateResponse(code, response, responseId) {
if (code !== "default" && (code < 100 || code > 599)) {
throw new SyntaxError(`Validation failed. ${responseId} has an invalid response code (${code})`);
}
let headers = Object.keys(response.headers || {});
for (let headerName of headers) {
let header = response.headers[headerName];
let headerId = responseId + "/headers/" + headerName;
validateSchema(header, headerId, primitiveTypes);
}
if (response.schema) {
let validTypes = schemaTypes.concat("file");
if (validTypes.indexOf(response.schema.type) === -1) {
throw new SyntaxError(
`Validation failed. ${responseId} has an invalid response schema type (${response.schema.type})`,
);
} else {
validateSchema(response.schema, responseId + "/schema", validTypes);
}
}
}
/**
* Validates the given Swagger schema object.
*
* @param {object} schema - A Schema object, from the Swagger API
* @param {string} schemaId - A value that uniquely identifies the schema object
* @param {string[]} validTypes - An array of the allowed schema types
*/
function validateSchema(schema, schemaId, validTypes) {
if (validTypes.indexOf(schema.type) === -1) {
throw new SyntaxError(`Validation failed. ${schemaId} has an invalid type (${schema.type})`);
}
if (schema.type === "array" && !schema.items) {
throw new SyntaxError(`Validation failed. ${schemaId} is an array, so it must include an "items" schema`);
}
}
/**
* Validates that the declared properties of the given Swagger schema object actually exist.
*
* @param {object} schema - A Schema object, from the Swagger API
* @param {string} schemaId - A value that uniquely identifies the schema object
*/
function validateRequiredPropertiesExist(schema, schemaId) {
/**
* Recursively collects all properties of the schema and its ancestors. They are added to the props object.
*/
function collectProperties(schemaObj, props) {
if (schemaObj.properties) {
for (let property in schemaObj.properties) {
if (schemaObj.properties.hasOwnProperty(property)) {
props[property] = schemaObj.properties[property];
}
}
}
if (schemaObj.allOf) {
for (let parent of schemaObj.allOf) {
collectProperties(parent, props);
}
}
}
// The "required" keyword is only applicable for objects
if (Array.isArray(schema.type) && !schema.type.includes("object")) {
return;
} else if (!Array.isArray(schema.type) && schema.type !== "object") {
return;
}
if (schema.required && Array.isArray(schema.required)) {
let props = {};
collectProperties(schema, props);
for (let requiredProperty of schema.required) {
if (!props[requiredProperty]) {
throw new SyntaxError(
`Validation failed. Property '${requiredProperty}' listed as required but does not exist in '${schemaId}'`,
);
}
}
}
}
+88
View File
@@ -0,0 +1,88 @@
{
"name": "@apidevtools/swagger-parser",
"version": "12.1.0",
"description": "Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers",
"keywords": [
"swagger",
"openapi",
"open-api",
"json",
"yaml",
"parse",
"parser",
"validate",
"validator",
"validation",
"spec",
"specification",
"schema",
"reference",
"dereference"
],
"contributors": [
{
"name": "James Messinger"
},
{
"name": "JonLuca DeCaro",
"email": "apis@jonlu.ca"
}
],
"homepage": "https://apidevtools.com/swagger-parser/",
"repository": {
"type": "git",
"url": "https://github.com/APIDevTools/swagger-parser.git"
},
"license": "MIT",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
"lib"
],
"scripts": {
"clean": "rimraf .nyc_output coverage",
"lint": "eslint lib test",
"lint:fix": "eslint --fix lib test",
"test": "npm run test:node && npm run test:typescript",
"test:node": "mocha",
"test:typescript": "tsc --noEmit --strict --skipDefaultLibCheck --skipLibCheck --lib esnext,dom test/specs/typescript-definition.spec.ts",
"coverage": "npm run coverage:node",
"coverage:node": "cross-env QUICK_TEST=true nyc mocha"
},
"devDependencies": {
"@eslint/compat": "^1.3.0",
"@eslint/js": "^9.29.0",
"@jsdevtools/host-environment": "^2.1.2",
"@types/node": "^24.0.3",
"chai": "^5",
"cross-env": "^7.0.3",
"esbuild": "^0.25.5",
"esbuild-plugin-polyfill-node": "^0.3.0",
"eslint": "^9.29.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-jsdoc": "^51.0.1",
"eslint-plugin-prettier": "^5.4.1",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^16.2.0",
"js-yaml": "^4.1.0",
"mocha": "^11.6.0",
"nyc": "^17.1.0",
"openapi-types": "^12.1.3",
"prettier": "^3.5.3",
"rimraf": "^6.0.1",
"typescript": "^5.8.3",
"typescript-eslint": "^8.34.1"
},
"dependencies": {
"@apidevtools/json-schema-ref-parser": "14.0.1",
"@apidevtools/openapi-schemas": "^2.1.0",
"@apidevtools/swagger-methods": "^3.0.2",
"ajv": "^8.17.1",
"ajv-draft-04": "^1.0.0",
"call-me-maybe": "^1.0.2"
},
"peerDependencies": {
"openapi-types": ">=7"
},
"packageManager": "yarn@4.9.1"
}