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

@pactflow/swagger-mock-validator

Package Overview
Dependencies
Maintainers
6
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pactflow/swagger-mock-validator - npm Package Compare versions

Comparing version 11.3.0 to 11.3.1

.whitesource

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="11.3.1"></a>
## [11.3.1](https://github.com/pactflow/swagger-mock-validator/compare/11.3.0...11.3.1) (2023-03-20)
### Bug Fixes
* replace unmaintained dependency request for axios (merge from upstream) ([af43f68](https://github.com/pactflow/swagger-mock-validator/commit/af43f68))
<a name="11.3.0"></a>

@@ -2,0 +12,0 @@ # [11.3.0](https://github.com/pactflow/swagger-mock-validator/compare/11.2.0...11.3.0) (2022-07-07)

68

dist/swagger-mock-validator/clients/http-client.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpClient = void 0;
const request = require("request");
const hasHttp2xxStatusCode = (response) => response.statusCode && response.statusCode >= 200 && response.statusCode <= 299;
const axios_1 = require("axios");
class HttpClient {
static getRequestOptions(url, auth) {
let requestOptions = {
timeout: 30000,
url
};
if (auth) {
requestOptions = Object.assign(Object.assign({}, requestOptions), { headers: {
authorization: 'Basic ' + Buffer.from(auth).toString('base64')
} });
}
return requestOptions;
}
get(url, auth) {
return new Promise((resolve, reject) => {
const requestOptions = HttpClient.getRequestOptions(url, auth);
request(requestOptions, (error, response, body) => {
if (error) {
reject(error);
}
else if (response.statusCode !== 200) {
reject(new Error(`Expected 200 but received ${response.statusCode}`));
}
else {
resolve(body);
}
return __awaiter(this, void 0, void 0, function* () {
const headers = auth
? { authorization: 'Basic ' + Buffer.from(auth).toString('base64') }
: {};
const response = yield axios_1.default.get(url, {
headers,
timeout: 30000,
transformResponse: (data) => data,
validateStatus: (status) => status === 200
});
return response.data;
});
}
post(url, body) {
const requestOptions = {
body,
json: true,
method: 'POST',
timeout: 5000,
url
};
return new Promise((resolve, reject) => {
request(requestOptions, (error, response) => {
if (error) {
reject(error);
}
else if (!hasHttp2xxStatusCode(response)) {
reject(new Error(`Expected 2xx but received ${response.statusCode}}`));
}
else {
resolve();
}
return __awaiter(this, void 0, void 0, function* () {
yield axios_1.default.post(url, body, {
timeout: 5000,
validateStatus: (status) => status >= 200 && status <= 299
});

@@ -55,0 +35,0 @@ });

# Pact Support
Pact v1, v2, and v3 specifications are supported.
Pact v1, v2, v3 and v4 specifications are supported.
This is a list of all the relevant field names in Pact and if the validation supports them.
When using [Pact specification V4](https://github.com/pact-foundation/pact-specification/tree/version-4) note that only interactions with type "Synchronous/HTTP" are validated. Validation will ignore other interaction types such as "Asynchronous/Messages" which cannot be directly compared to an OAS.
## Pact Object

@@ -7,0 +9,0 @@

{
"name": "@pactflow/swagger-mock-validator",
"version": "11.3.0",
"version": "11.3.1",
"description": "A CLI tool to validate mocks against swagger/OpenApi specs.",

@@ -37,3 +37,2 @@ "bin": {

"@types/q": "^1.0.0",
"@types/request": "^2.0.3",
"@types/validator": "^13.1.0",

@@ -63,2 +62,3 @@ "@types/verror": "^1.9.0",

"ajv": "^6.12.6",
"axios": "^0.27.2",
"commander": "^7.0.0",

@@ -70,3 +70,2 @@ "decimal.js": "^10.2.0",

"openapi-types": "^7.0.1",
"request": "^2.87.0",
"swagger-parser": "^10.0.2",

@@ -73,0 +72,0 @@ "uuidjs": "^4.0.3",

@@ -6,3 +6,3 @@ # Swagger Mock Validator

- A command line tool that confirms mock request and responses conform to the schema specified in a Swagger 2 or OpenApi 3 specification.
- Supports mocks in Pact format (1.0, 1.1, 2.0 or 3.0) and the [Pact Broker](https://github.com/bethesque/pact_broker) (1.8.0 or higher)
- Supports mocks in Pact format (1.0, 1.1, 2.0, 3.0 and 4.0) and the [Pact Broker](https://github.com/bethesque/pact_broker) (1.8.0 or higher)
- Supports local files and urls

@@ -9,0 +9,0 @@ - Supports Swagger/OpenApi files in json or yaml format

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