@pactflow/openapi-pact-comparator 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +20 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +19 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +19 -9
- package/dist/index.mjs.map +1 -1
- package/dist/src/compare/utils/statusCodes.d.ts +1 -0
- package/package.json +5 -5
package/dist/cli.cjs
CHANGED
|
@@ -11835,6 +11835,15 @@ const convertExclusiveMinMax = (s) => {
|
|
|
11835
11835
|
delete s.exclusiveMinimum;
|
|
11836
11836
|
}
|
|
11837
11837
|
};
|
|
11838
|
+
const cleanupDiscriminators = (s) => {
|
|
11839
|
+
// no-op from a validation perspective
|
|
11840
|
+
if (s.discriminator?.mapping) {
|
|
11841
|
+
delete s.discriminator.mapping;
|
|
11842
|
+
}
|
|
11843
|
+
if (s.discriminator && !s.oneOf) {
|
|
11844
|
+
delete s.discriminator;
|
|
11845
|
+
}
|
|
11846
|
+
};
|
|
11838
11847
|
const minimumSchema = (originalSchema, oas) => {
|
|
11839
11848
|
const refToAdd = [];
|
|
11840
11849
|
const refAdded = [];
|
|
@@ -11842,10 +11851,6 @@ const minimumSchema = (originalSchema, oas) => {
|
|
|
11842
11851
|
if (s.$ref && !refToAdd.includes(s.$ref) && !refAdded.includes(s.$ref)) {
|
|
11843
11852
|
refToAdd.push(s.$ref);
|
|
11844
11853
|
}
|
|
11845
|
-
// no-op from a validation perspective
|
|
11846
|
-
if (s.discriminator?.mapping) {
|
|
11847
|
-
delete s.discriminator.mapping;
|
|
11848
|
-
}
|
|
11849
11854
|
};
|
|
11850
11855
|
const handleNullableSchema = (s) => {
|
|
11851
11856
|
if (s.$ref) {
|
|
@@ -11864,6 +11869,7 @@ const minimumSchema = (originalSchema, oas) => {
|
|
|
11864
11869
|
const schema = cloneDeep(originalSchema);
|
|
11865
11870
|
delete schema.description;
|
|
11866
11871
|
delete schema.example;
|
|
11872
|
+
traverse(schema, cleanupDiscriminators);
|
|
11867
11873
|
traverse(schema, collectReferences);
|
|
11868
11874
|
traverse(schema, handleNullableSchema);
|
|
11869
11875
|
traverse(schema, convertExclusiveMinMax);
|
|
@@ -15923,6 +15929,8 @@ function* compareReqSecurity(ajv, route, interaction, index, config) {
|
|
|
15923
15929
|
}
|
|
15924
15930
|
}
|
|
15925
15931
|
|
|
15932
|
+
const patternedStatus = (status) => `${Math.floor(status / 100)}XX`;
|
|
15933
|
+
|
|
15926
15934
|
const canValidate = (contentType = "") => {
|
|
15927
15935
|
return !!findMatchingType(contentType, ["application/json"]);
|
|
15928
15936
|
};
|
|
@@ -15932,9 +15940,9 @@ function* compareResBody(ajv, route, interaction, index, config) {
|
|
|
15932
15940
|
const { body, status } = interaction.response;
|
|
15933
15941
|
const requestHeaders = new Headers(interaction.request.headers);
|
|
15934
15942
|
const statusResponse = operation.responses?.[status];
|
|
15935
|
-
const
|
|
15936
|
-
|
|
15937
|
-
const response = statusResponse || defaultResponse;
|
|
15943
|
+
const patternedResponse = operation.responses?.[patternedStatus(status)];
|
|
15944
|
+
const defaultResponse = operation.responses?.["default"];
|
|
15945
|
+
const response = statusResponse || patternedResponse || defaultResponse;
|
|
15938
15946
|
if (!response) {
|
|
15939
15947
|
yield {
|
|
15940
15948
|
code: "response.status.unknown",
|
|
@@ -15962,7 +15970,7 @@ function* compareResBody(ajv, route, interaction, index, config) {
|
|
|
15962
15970
|
const schema = dereferencedResponse?.schema ||
|
|
15963
15971
|
getByContentType(dereferencedResponse.content || {}, contentType)?.schema;
|
|
15964
15972
|
const value = body;
|
|
15965
|
-
if (!statusResponse) {
|
|
15973
|
+
if (!statusResponse && !patternedResponse) {
|
|
15966
15974
|
yield {
|
|
15967
15975
|
code: "response.status.default",
|
|
15968
15976
|
message: `Response status code matched default response in spec file: ${status}`,
|
|
@@ -16029,7 +16037,9 @@ function* compareResBody(ajv, route, interaction, index, config) {
|
|
|
16029
16037
|
|
|
16030
16038
|
function* compareResHeader(ajv, route, interaction, index, _config) {
|
|
16031
16039
|
const { method, oas, operation, path } = route.store;
|
|
16032
|
-
const
|
|
16040
|
+
const { status } = interaction.response;
|
|
16041
|
+
const response = operation.responses[status] ||
|
|
16042
|
+
operation.responses[patternedStatus(status)] ||
|
|
16033
16043
|
operation.responses["default"];
|
|
16034
16044
|
// no response found
|
|
16035
16045
|
// -----------------
|
|
@@ -32047,7 +32057,7 @@ class Comparator {
|
|
|
32047
32057
|
}
|
|
32048
32058
|
}
|
|
32049
32059
|
|
|
32050
|
-
var version = "1.
|
|
32060
|
+
var version = "1.6.0";
|
|
32051
32061
|
var packageJson = {
|
|
32052
32062
|
version: version};
|
|
32053
32063
|
|