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";
Browser support
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.
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.
Use the current Node.js LTS release for development. TypeScript tests use the TypeScript 7 compiler, while ESLint uses the TypeScript 6 compatibility API via Microsoft's recommended package aliases.
To test the project locally on your computer:
Clone this repo git clone https://github.com/APIDevTools/swagger-parser.git
Install dependencies pnpm install
Run the tests pnpm test
Check the code coverage pnpm run coverage
License
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.
Big Thanks To
Thanks to these awesome companies for their support of Open Source developers ❤