
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
@apidevtools/swagger-parser
Advanced tools
Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers
$ref pointers, including external files and URLs$ref pointers$ref pointers, giving you a normal JavaScript object that's easy to work with$ref pointers to the same value always resolve to the same object instanceSwaggerParser.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 syntax instead. The following example is the same as above:
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
Install using npm:
npm install @apidevtools/swagger-parser
When using Swagger Parser in Node.js apps, you'll probably want to use CommonJS syntax:
const SwaggerParser = require("@apidevtools/swagger-parser");
When using a transpiler such as Babel or TypeScript, or a bundler such as Webpack or Rollup, you can use ECMAScript modules syntax instead:
import * as SwaggerParser from "@apidevtools/swagger-parser";
Swagger Parser supports recent versions of every major web browser. Older browsers may require Babel and/or polyfills.
To use Swagger Parser in a browser, you'll need to use a bundling tool such as Webpack, Rollup, Parcel, or Browserify. Some bundlers may require a bit of configuration, such as setting browser: true in rollup-plugin-resolve.
Full API documentation is available right here
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 for more details and information on how to mitigate LFI.
I welcome any contributions, enhancements, and bug-fixes. Open an issue on GitHub and submit a pull request.
To test the project locally on your computer:
Clone this repo
git clone https://github.com/APIDevTools/swagger-parser.git
Install dependencies
npm install
Run the tests
npm test
Check the code coverage
npm run coverage
Swagger Parser is 100% free and open-source, under the MIT license. Use it however you want.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work.
Thanks to these awesome companies for their support of Open Source developers ❤
This package generates swagger doc based on JSDoc comments. Unlike @apidevtools/swagger-parser, it is more focused on creating the swagger documentation from code rather than parsing and validating existing swagger files.
This package allows you to serve auto-generated swagger-ui generated API docs from express, based on a swagger.json file. It is complementary to @apidevtools/swagger-parser, which can be used to validate and parse the swagger.json file before serving it with swagger-ui-express.
This is an IBM package that validates OpenAPI specifications against the OpenAPI 3.0 or 2.0 specifications. It is similar to @apidevtools/swagger-parser in that it validates OpenAPI documents, but it is maintained by IBM and may have different validation features or standards.
FAQs
Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers
The npm package @apidevtools/swagger-parser receives a total of 3,023,376 weekly downloads. As such, @apidevtools/swagger-parser popularity was classified as popular.
We found that @apidevtools/swagger-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.