@pactflow/swagger-mock-validator
Advanced tools
Comparing version 11.3.0 to 11.3.1
@@ -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) |
"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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
212146
28
83
2906
+ Addedaxios@^0.27.2
+ Addedaxios@0.27.2(transitive)
+ Addedextsprintf@1.4.1(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.1(transitive)
- Removedrequest@^2.87.0
- Removedasn1@0.2.6(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removeddashdash@1.14.1(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.13.0(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)