pact-gen-ts
Version:
Generating pact files from typescript definitions
23 lines (22 loc) • 1.36 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PactAxiosQuery = void 0;
const type_representation_1 = require("../../core/type-representation");
const create_pact_example_object_1 = require("../../core/create-pact-example-object");
const create_pact_matching_rules_1 = require("../../core/create-pact-matching-rules");
const qs_1 = __importDefault(require("qs"));
class PactAxiosQuery {
constructor(axios, sourceFile, queryArrayFormat) {
const queryElementType = axios.getQueryType();
if (queryElementType) {
const basicTypeRepresentationOfRequestBody = (0, type_representation_1.getTypeRepresentation)(queryElementType, sourceFile);
const exampleRepresentationOfQueryObject = (0, create_pact_example_object_1.changeObjectRepresentationIntoExample)(basicTypeRepresentationOfRequestBody);
this.query = qs_1.default.stringify(exampleRepresentationOfQueryObject, { arrayFormat: queryArrayFormat || 'brackets' });
this.matchingRules = (0, create_pact_matching_rules_1.changeObjectRepresentationIntoMatchingRules)(basicTypeRepresentationOfRequestBody, '$.query');
}
}
}
exports.PactAxiosQuery = PactAxiosQuery;