Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swagger-parser

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-parser - npm Package Compare versions

Comparing version 7.0.1 to 8.0.0

13

CHANGELOG.md

@@ -6,2 +6,11 @@ # Change Log

## [v8.0.0](https://github.com/APIDevTools/swagger-parser/tree/v8.0.0) (2019-06-22)
#### Potentially Breaking Changes
- [The `validate()` function](https://apidevtools.org/swagger-parser/docs/swagger-parser.html#validateapi-options-callback) now uses [the official JSON Schemas](https://github.com/OAI/OpenAPI-Specification/tree/master/schemas) for Swagger 2.0 and OpenAPI 3.0 schema validation. We tested this change on [over 1,500 real-world APIs](https://apis.guru/browse-apis/) and there were **no breaking changes**, but we're bumped the major version number just to be safe.
[Full Changelog](https://github.com/APIDevTools/swagger-parser/compare/v7.0.1...v8.0.0)
## [v7.0.0](https://github.com/APIDevTools/swagger-parser/tree/v7.0.0) (2019-06-12)

@@ -95,3 +104,3 @@

Updated to the latest version of [the Official Swagger 2.0 Schema](https://www.npmjs.com/package/swagger-schema-official). The schema [hadn't been updated for six months](https://github.com/swagger-api/swagger-spec/issues/335), so Swagger Parser was missing [several recent changes](https://github.com/swagger-api/swagger-spec/commits/master/schemas/v2.0/schema.json).
Updated to the latest version of [the Official Swagger 2.0 Schema](https://www.npmjs.com/package/swagger-schema-official). The schema [hadn't been updated for six months](https://github.com/OAI/OpenAPI-Specification/issues/335), so Swagger Parser was missing [several recent changes](https://github.com/OAI/OpenAPI-Specification/commits/master/schemas/v2.0/schema.json).

@@ -122,3 +131,3 @@ [Full Changelog](https://github.com/APIDevTools/swagger-parser/compare/v3.2.0...v3.3.0)

**Swagger 2.0 Compliant**<br>
Previous versions of Swagger Parser were based on early drafts of Swagger 2.0, and were not compliant with [the final version of the spec](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md). Swagger Parser v3.0 is now compliant with the final spec as well as related specs, such as [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03) and [JSON Pointer](https://tools.ietf.org/html/rfc6901)
Previous versions of Swagger Parser were based on early drafts of Swagger 2.0, and were not compliant with [the final version of the spec](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md). Swagger Parser v3.0 is now compliant with the final spec as well as related specs, such as [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03) and [JSON Pointer](https://tools.ietf.org/html/rfc6901)

@@ -125,0 +134,0 @@ **All-New API**<br>

2

lib/index.js

@@ -184,5 +184,5 @@ "use strict";

* The Swagger object
* https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object
* https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#swagger-object
*
* @typedef {{swagger: string, info: {}, paths: {}}} SwaggerObject
*/

@@ -6,2 +6,3 @@ "use strict";

const ZSchema = require("z-schema");
const { openapi } = require("openapi-schemas");

@@ -19,6 +20,5 @@ module.exports = validateSchema;

// Choose the appropriate schema (Swagger or OpenAPI)
let schema = api.swagger
? require("swagger-schema-official/schema.json")
: require("openapi-schema-validation/schema/openapi-3.0.json");
let schema = api.swagger ? openapi.v2 : openapi.v3;
// Validate against the schema
let isValid = zSchema.validate(api, schema);

@@ -37,2 +37,11 @@

function initializeZSchema () {
// HACK: Delete the OpenAPI schema IDs because ZSchema can't resolve them
delete openapi.v2.id;
delete openapi.v3.id;
// The OpenAPI 3.0 schema uses "uri-reference" formats.
// Assume that any non-whitespace string is valid.
ZSchema.registerFormat("uri-reference", (value) => value.trim().length > 0);
// Configure ZSchema
return new ZSchema({

@@ -39,0 +48,0 @@ breakOnFirstError: true,

{
"name": "swagger-parser",
"version": "7.0.1",
"version": "8.0.0",
"description": "Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers",

@@ -55,6 +55,6 @@ "keywords": [

"@babel/polyfill": "^7.4.4",
"@types/node": "^12.0.7",
"@types/node": "^12.0.10",
"chai": "^4.2.0",
"coveralls": "^3.0.4",
"eslint": "^5.16.0",
"eslint": "^6.0.0",
"eslint-config-modular": "^7.0.0",

@@ -78,8 +78,7 @@ "host-environment": "^1.1.3",

"ono": "^5.0.1",
"openapi-schema-validation": "^0.4.2",
"openapi-schemas": "^1.0.0",
"openapi-types": "^1.3.5",
"swagger-methods": "^2.0.0",
"swagger-schema-official": "2.0.0-bab6bed",
"z-schema": "^4.1.0"
}
}

@@ -19,3 +19,3 @@ Swagger 2.0 and OpenAPI 3.0 parser/validator

- 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) or [OpenAPI 3.0 Schema](https://github.com/kogosoftwarellc/open-api/blob/master/packages/openapi-schema-validation/schema/openapi-3.0.json)
- 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.org/swagger-parser/docs/swagger-parser.html#resolveapi-options-callback) all `$ref` pointers, including external files and URLs

@@ -25,3 +25,3 @@ - Can [bundle](https://apidevtools.org/swagger-parser/docs/swagger-parser.html#bundleapi-options-callback) all your Swagger files into a single file that only has _internal_ `$ref` pointers

- **[Tested](https://travis-ci.com/APIDevTools/swagger-parser)** in Node.js and all modern web browsers on Mac, Windows, and Linux
- Tested on **[over 1,000 real-world APIs](https://apis.guru/browse-apis/)** from Google, Instagram, Spotify, etc.
- Tested on **[over 1,500 real-world APIs](https://apis.guru/browse-apis/)** from Google, Instagram, Spotify, etc.
- Supports [circular references](https://apidevtools.org/swagger-parser/docs/#circular-refs), nested references, back-references, and cross-references

@@ -28,0 +28,0 @@ - Maintains object reference equality &mdash; `$ref` pointers to the same value always resolve to the same object instance

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc