diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9021f53 Binary files /dev/null and b/.DS_Store differ diff --git a/CHANGELOG.md b/CHANGELOG.md index a687438..bc876cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# [11.1.0](https://github.com/pactflow/swagger-mock-validator/compare/11.0.0...11.1.0) (2022-06-14) + + +### Bug Fixes + +* Convert pact spec 3 headers to v1 format ([a0584b0](https://github.com/pactflow/swagger-mock-validator/commit/a0584b0590a5a857cb1bfa302595e892aee781ab)) + + + # [11.0.0](https://github.com/pactflow/swagger-mock-validator/compare/10.3.0...11.0.0) (2022-04-22) diff --git a/dist/swagger-mock-validator/mock-parser/pact/pact-parser.js b/dist/swagger-mock-validator/mock-parser/pact/pact-parser.js index 2ff77d2..8b6224c 100644 --- a/dist/swagger-mock-validator/mock-parser/pact/pact-parser.js +++ b/dist/swagger-mock-validator/mock-parser/pact/pact-parser.js @@ -21,6 +21,14 @@ const parseValues = (values, location, parentInteraction) => { return result; }, {}); }; +const parseHeaders = (headers, location, parentInteraction) => { + for (const key in headers) { + if (typeof headers[key] !== 'string') { + headers[key] = headers[key].toString(); + } + } + return parseValues(headers, location, parentInteraction); +}; const isPactV1RequestQuery = (query) => typeof query === 'string'; const parseAsPactV1RequestQuery = (requestQuery) => { const parsedQueryAsStringsOrArrayOfStrings = querystring.parse(requestQuery); @@ -76,7 +84,7 @@ const parseInteraction = (interaction, interactionIndex, mockPathOrUrl) => { parentInteraction: parsedInteraction, value: interaction.request.body }; - parsedInteraction.requestHeaders = parseValues(interaction.request.headers, `${parsedInteraction.location}.request.headers`, parsedInteraction); + parsedInteraction.requestHeaders = parseHeaders(interaction.request.headers, `${parsedInteraction.location}.request.headers`, parsedInteraction); parsedInteraction.requestMethod = { location: `${parsedInteraction.location}.request.method`, parentInteraction: parsedInteraction, @@ -94,7 +102,7 @@ const parseInteraction = (interaction, interactionIndex, mockPathOrUrl) => { parentInteraction: parsedInteraction, value: interaction.response.body }; - parsedInteraction.responseHeaders = parseValues(interaction.response.headers, `${parsedInteraction.location}.response.headers`, parsedInteraction); + parsedInteraction.responseHeaders = parseHeaders(interaction.response.headers, `${parsedInteraction.location}.response.headers`, parsedInteraction); parsedInteraction.responseStatus = { location: `${parsedInteraction.location}.response.status`, parentInteraction: parsedInteraction, diff --git a/package.json b/package.json index 59b961f..f6d57be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pactflow/swagger-mock-validator", - "version": "11.0.0", + "version": "11.1.0", "description": "A CLI tool to validate mocks against swagger/OpenApi specs.", "bin": { "swagger-mock-validator": "./bin/swagger-mock-validator"