# swagger-parser
**Repository Path**: mirrors_davidB/swagger-parser
## Basic Information
- **Project Name**: swagger-parser
- **Description**: Swagger 2.0 parser and validator for Node and browsers
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-08-08
- **Last Updated**: 2026-06-20
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
------------------------------------------------
##### NOTICE: Swagger Parser v4.0 _beta_ is now available
You can install the beta using `npm install swagger-parser@beta`.
- [v4.0 code branch](https://github.com/BigstickCarpet/swagger-parser/tree/releases/4.0.0)
- [v4.0 documentation](https://github.com/BigstickCarpet/swagger-parser/tree/releases/4.0.0/docs)
- [v4.0 changelog](https://github.com/BigstickCarpet/swagger-parser/blob/releases/4.0.0/CHANGELOG.md)
------------------------------------------------
Swagger Parser v3.4
============================
#### Swagger 2.0 parser and validator for Node and browsers
[](https://travis-ci.org/BigstickCarpet/swagger-parser)
[](https://david-dm.org/BigstickCarpet/swagger-parser)
[](https://coveralls.io/r/BigstickCarpet/swagger-parser)
[](https://codeclimate.com/github/BigstickCarpet/swagger-parser)
[](https://www.codacy.com/public/jamesmessinger/swagger-parser)
[](http://inch-ci.org/github/BigstickCarpet/swagger-parser)
[](https://APIs.guru)
[](https://www.npmjs.com/package/swagger-parser)
[](http://bower.io/)
[](LICENSE)
[](https://saucelabs.com/u/swagger-parser)
[](http://bigstickcarpet.com/swagger-parser/)
Features
--------------------------
- Parses Swagger specs in **JSON** or **YAML** format
- Validates against the [Swagger 2.0 schema](https://github.com/swagger-api/swagger-spec/blob/master/schemas/v2.0/schema.json) _and_ the [Swagger 2.0 spec](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md)
- [Resolves](docs/swagger-parser.md#resolveapi-options-callback) all `$ref` pointers, including external files and URLs
- Can [bundle](docs/swagger-parser.md#bundleapi-options-callback) all your Swagger files into a single file that only has _internal_ `$ref` pointers
- Can [dereference](docs/swagger-parser.md#dereferenceapi-options-callback) all `$ref` pointers, giving you a normal JavaScript object that's easy to work with
- Configurable caching of external files and URLs
- **[Tested](http://bigstickcarpet.github.io/swagger-parser/tests/index.html)** in Node, IO.js, and all modern web browsers on Mac, Windows, Linux, iOS, and Android
- Tested on **[over 200 real-world APIs](https://apis.guru)** from Google, Instagram, Cisco, etc.
- Supports [circular references](docs/README.md#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/BigstickCarpet/swagger-cli)
- [Swagger Express Middleware](https://github.com/BigstickCarpet/swagger-express-middleware)
Example
--------------------------
```javascript
SwaggerParser.validate(myAPI, function(err, api) {
if (err) {
console.error(err);
}
else {
console.log("API name: %s, Version: %s", api.info.title, api.info.version);
}
});
```
Or use [Promises syntax](http://javascriptplayground.com/blog/2015/02/promises/) instead. The following example is the same as above:
```javascript
SwaggerParser.validate(myAPI)
.then(function(api) {
console.log("API name: %s, Version: %s", api.info.title, api.info.version);
})
.catch(function(err) {
console.error(err);
});
```
For more detailed examples, please see the [API Documentation](docs/README.md)
Installation
--------------------------
#### Node
Install using [npm](https://docs.npmjs.com/getting-started/what-is-npm):
```bash
npm install swagger-parser
```
Then require it in your code:
```javascript
var SwaggerParser = require('swagger-parser');
```
#### Web Browsers
Install using [bower](http://bower.io/):
```bash
bower install swagger-parser
```
Then reference [`swagger-parser.js`](dist/swagger-parser.js) or [`swagger-parser.min.js`](dist/swagger-parser.min.js) in your HTML:
```html
```
Or, if you're using AMD (Require.js), then import it into your module:
```javascript
define(["swagger-parser"], function(SwaggerParser) { /* your module's code */ })
```
API Documentation
--------------------------
Full API documentation is available [right here](docs/README.md)
Contributing
--------------------------
I welcome any contributions, enhancements, and bug-fixes. [File an issue](https://github.com/BigstickCarpet/swagger-parser/issues) on GitHub and [submit a pull request](https://github.com/BigstickCarpet/swagger-parser/pulls).
#### Building/Testing
To build/test the project locally on your computer:
1. __Clone this repo__
`git clone https://github.com/bigstickcarpet/swagger-parser.git`
2. __Install dependencies__
`npm install`
3. __Run the build script__
`npm run build`
4. __Run the unit tests__
`npm run mocha` (test in Node)
`npm run karma` (test in web browsers)
`npm test` (test in Node and browsers, and report code coverage)
5. __Start the local web server__
`npm start` (then browse to [http://localhost:8080/www/index.html](http://bigstickcarpet.com/swagger-parser/www/index.html) or [http://localhost:8080/tests/index.html](http://bigstickcarpet.com/swagger-parser/tests/index.html))
License
--------------------------
Swagger Parser is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.