@pactflow/openapi-pact-comparator 1.7.1 → 1.8.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 +21 -7
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +20 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +20 -6
- package/dist/index.mjs.map +1 -1
- package/dist/src/documents/pact.d.ts +3 -2
- package/dist/src/results/index.d.ts +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -19471,7 +19471,8 @@ const Pact = Type.Object({
|
|
|
19471
19471
|
version: Type.String(),
|
|
19472
19472
|
})),
|
|
19473
19473
|
})),
|
|
19474
|
-
interactions: Type.Array(Interaction),
|
|
19474
|
+
interactions: Type.Optional(Type.Array(Interaction)),
|
|
19475
|
+
messages: Type.Optional(Type.Array(Type.Unknown())),
|
|
19475
19476
|
});
|
|
19476
19477
|
const supportedInteractions = (i) => !i.type || i.type.toLowerCase() === "synchronous/http";
|
|
19477
19478
|
const parseAsPactV4Body = (body) => {
|
|
@@ -19545,10 +19546,11 @@ const interactionV4 = (i) => ({
|
|
|
19545
19546
|
const ajv = new Ajv$1();
|
|
19546
19547
|
const validate = ajv.compile(Pact);
|
|
19547
19548
|
const parse = (pact) => {
|
|
19548
|
-
const { metadata, interactions } = pact;
|
|
19549
|
+
const { metadata, interactions, messages } = pact;
|
|
19549
19550
|
const isValid = validate({
|
|
19550
19551
|
metadata,
|
|
19551
|
-
interactions: interactions
|
|
19552
|
+
interactions: interactions?.filter(supportedInteractions),
|
|
19553
|
+
messages,
|
|
19552
19554
|
});
|
|
19553
19555
|
if (!isValid) {
|
|
19554
19556
|
throw new ParserError(validate.errors);
|
|
@@ -19560,9 +19562,10 @@ const parse = (pact) => {
|
|
|
19560
19562
|
const interactionParser = version >= 4 ? interactionV4 : version >= 3 ? interactionV3 : interactionV1;
|
|
19561
19563
|
return {
|
|
19562
19564
|
metadata,
|
|
19563
|
-
interactions: interactions
|
|
19565
|
+
interactions: interactions?.map((i) => supportedInteractions(i)
|
|
19564
19566
|
? interactionParser(i)
|
|
19565
19567
|
: { _skip: true }),
|
|
19568
|
+
messages,
|
|
19566
19569
|
};
|
|
19567
19570
|
};
|
|
19568
19571
|
class ParserError extends Error {
|
|
@@ -24343,9 +24346,15 @@ class Comparator {
|
|
|
24343
24346
|
this.#router = setupRouter(this.#oas, this.#config);
|
|
24344
24347
|
}
|
|
24345
24348
|
const parsedPact = parse(pact);
|
|
24346
|
-
|
|
24349
|
+
const parsedInteractions = parsedPact.interactions || [];
|
|
24350
|
+
const UNSUPPORTED_INTERACTION_WARNING = {
|
|
24351
|
+
code: "interaction.type.unsupported",
|
|
24352
|
+
message: `Non-HTTP Interaction is not supported, OPC can only compare HTTP interactions.`,
|
|
24353
|
+
type: "warning",
|
|
24354
|
+
};
|
|
24355
|
+
for (const [index, interaction] of parsedInteractions.entries()) {
|
|
24347
24356
|
if (interaction._skip) {
|
|
24348
|
-
|
|
24357
|
+
yield UNSUPPORTED_INTERACTION_WARNING;
|
|
24349
24358
|
continue;
|
|
24350
24359
|
}
|
|
24351
24360
|
const { method, path, query } = interaction.request;
|
|
@@ -24393,6 +24402,11 @@ class Comparator {
|
|
|
24393
24402
|
yield* compareResHeader(this.#ajvCoerce, route, interaction, index, this.#config);
|
|
24394
24403
|
yield* compareResBody(this.#ajvNocoerce, route, interaction, index, this.#config);
|
|
24395
24404
|
}
|
|
24405
|
+
if (parsedPact.messages) {
|
|
24406
|
+
for (const [_message] of parsedPact.messages.entries()) {
|
|
24407
|
+
yield UNSUPPORTED_INTERACTION_WARNING;
|
|
24408
|
+
}
|
|
24409
|
+
}
|
|
24396
24410
|
}
|
|
24397
24411
|
}
|
|
24398
24412
|
|