swagger-tests
Version:
A typescript framework for testing an api against a swagger 3.0 json file.
43 lines • 1.22 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const underscore_1 = require("underscore");
const actionMapping = {
post: 'create',
put: 'update',
get: 'index',
delete: 'delete',
};
const statusMapping = {
404: 'notFound',
422: 'bad',
500: 'unexpected',
401: 'unauthorized',
};
class OperationSupport {
constructor(operationName) {
const routeSplit = operationName.split('#');
this.route = routeSplit[0];
this.restMethod = routeSplit[1].split('::')[0];
this.statusCode = routeSplit[1].split('::')[1];
}
get restAction() {
if (this.restMethod == 'get' && underscore_1.contains(this.route, '{id}')) {
return 'show';
}
else {
return actionMapping[this.restMethod];
}
}
get statusString() {
let status = statusMapping[this.statusCode];
if (this.statusCodeInt >= 200 && this.statusCodeInt < 400) {
status = 'success';
}
return status;
}
get statusCodeInt() {
return parseInt(this.statusCode, 10);
}
}
exports.OperationSupport = OperationSupport;
//# sourceMappingURL=operation.support.js.map
;