Skip to content

Commit

Permalink
chore: release 11.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 20, 2023
1 parent 8ac9d3e commit 659c0b6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 296 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<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>
# [11.3.0](https://github.com/pactflow/swagger-mock-validator/compare/11.2.0...11.3.0) (2022-07-07)

Expand Down
68 changes: 24 additions & 44 deletions dist/swagger-mock-validator/clients/http-client.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,36 @@
"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
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pactflow/swagger-mock-validator",
"version": "11.3.0",
"version": "11.3.1",
"description": "A CLI tool to validate mocks against swagger/OpenApi specs.",
"bin": {
"swagger-mock-validator": "./bin/swagger-mock-validator"
Expand Down
Loading

0 comments on commit 659c0b6

Please sign in to comment.