Skip to content
Closed
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
87 changes: 0 additions & 87 deletions .github/workflows/CI-CD.yaml

This file was deleted.

Binary file added .yarn/install-state.gz
Binary file not shown.
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# 🛠️ About This Fork
This is a fork of @apidevtools/swagger-parser created to improve Content Security Policy (CSP) compliance for secure web environments.

# 🚨 Why Fork?
The original package uses the following JSON Schema validators:

ajv

ajv-draft-04

Both rely on dynamic code generation (new Function()), which is blocked under CSP unless unsafe-eval is allowed. This presents security concerns for browser-based applications that enforce strict CSP rules.

# ✅ What Was Changed
🔁 Replaced ajv and ajv-draft-04 with z-schema, a JSON Schema validator that does not use eval or new Function(), making it CSP-safe.

🧪 Updated the internal validation logic to work with Z-Schema.

🔒 Ensures OpenAPI (Swagger 2.0 / OAS 3.0 / 3.1) schema validation can run in environments with strict CSP (e.g., browsers without unsafe-eval).


# 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)
Expand All @@ -23,10 +43,7 @@
- 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

Expand Down Expand Up @@ -58,21 +75,21 @@ For more detailed examples, please see the [API Documentation](https://apidevtoo
Install using [npm](https://docs.npmjs.com/about-npm/):

```bash
npm install @apidevtools/swagger-parser
npm install swagger-parser-zschema
```

## Usage

When using Swagger Parser in Node.js apps, you'll probably want to use **CommonJS** syntax:

```javascript
const SwaggerParser = require("@apidevtools/swagger-parser");
const SwaggerParser = require("swagger-parser-zschema");
```

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";
import * as SwaggerParser from "swagger-parser-zschema";
```

## Browser support
Expand All @@ -89,23 +106,6 @@ Full API documentation is available [right here](https://apidevtools.com/swagger

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

Expand Down
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import * as SwaggerParser from "@apidevtools/swagger-parser";
import * as SwaggerParser from "swagger-parser-zschema";
export = SwaggerParser;
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"use strict";
module.exports = require("@apidevtools/swagger-parser");
module.exports = require("swagger-parser-zschema");
8 changes: 4 additions & 4 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "swagger-parser",
"name": "swagger-parser-zschema",
"version": "X.X.X",
"description": "Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers",
"keywords": [
Expand All @@ -23,10 +23,10 @@
"name": "James Messinger",
"url": "https://jamesmessinger.com"
},
"homepage": "https://apitools.dev/swagger-parser/",

"repository": {
"type": "git",
"url": "https://github.com/APIDevTools/swagger-parser.git"
"url": "https://github.com/ibm-apiconnect/swagger-parser-zschema"
},
"license": "MIT",
"main": "index.js",
Expand All @@ -39,6 +39,6 @@
"node": ">=10"
},
"dependencies": {
"@apidevtools/swagger-parser": "X.X.X"
"swagger-parser-zschema": "X.X.X"
}
}
Loading