@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/cli.cjs
CHANGED
|
@@ -27632,7 +27632,8 @@ const Pact = Type.Object({
|
|
|
27632
27632
|
version: Type.String(),
|
|
27633
27633
|
})),
|
|
27634
27634
|
})),
|
|
27635
|
-
interactions: Type.Array(Interaction),
|
|
27635
|
+
interactions: Type.Optional(Type.Array(Interaction)),
|
|
27636
|
+
messages: Type.Optional(Type.Array(Type.Unknown())),
|
|
27636
27637
|
});
|
|
27637
27638
|
const supportedInteractions = (i) => !i.type || i.type.toLowerCase() === "synchronous/http";
|
|
27638
27639
|
const parseAsPactV4Body = (body) => {
|
|
@@ -27706,10 +27707,11 @@ const interactionV4 = (i) => ({
|
|
|
27706
27707
|
const ajv = new Ajv$1();
|
|
27707
27708
|
const validate = ajv.compile(Pact);
|
|
27708
27709
|
const parse = (pact) => {
|
|
27709
|
-
const { metadata, interactions } = pact;
|
|
27710
|
+
const { metadata, interactions, messages } = pact;
|
|
27710
27711
|
const isValid = validate({
|
|
27711
27712
|
metadata,
|
|
27712
|
-
interactions: interactions
|
|
27713
|
+
interactions: interactions?.filter(supportedInteractions),
|
|
27714
|
+
messages,
|
|
27713
27715
|
});
|
|
27714
27716
|
if (!isValid) {
|
|
27715
27717
|
throw new ParserError(validate.errors);
|
|
@@ -27721,9 +27723,10 @@ const parse = (pact) => {
|
|
|
27721
27723
|
const interactionParser = version >= 4 ? interactionV4 : version >= 3 ? interactionV3 : interactionV1;
|
|
27722
27724
|
return {
|
|
27723
27725
|
metadata,
|
|
27724
|
-
interactions: interactions
|
|
27726
|
+
interactions: interactions?.map((i) => supportedInteractions(i)
|
|
27725
27727
|
? interactionParser(i)
|
|
27726
27728
|
: { _skip: true }),
|
|
27729
|
+
messages,
|
|
27727
27730
|
};
|
|
27728
27731
|
};
|
|
27729
27732
|
class ParserError extends Error {
|
|
@@ -32504,9 +32507,15 @@ class Comparator {
|
|
|
32504
32507
|
this.#router = setupRouter(this.#oas, this.#config);
|
|
32505
32508
|
}
|
|
32506
32509
|
const parsedPact = parse(pact);
|
|
32507
|
-
|
|
32510
|
+
const parsedInteractions = parsedPact.interactions || [];
|
|
32511
|
+
const UNSUPPORTED_INTERACTION_WARNING = {
|
|
32512
|
+
code: "interaction.type.unsupported",
|
|
32513
|
+
message: `Non-HTTP Interaction is not supported, OPC can only compare HTTP interactions.`,
|
|
32514
|
+
type: "warning",
|
|
32515
|
+
};
|
|
32516
|
+
for (const [index, interaction] of parsedInteractions.entries()) {
|
|
32508
32517
|
if (interaction._skip) {
|
|
32509
|
-
|
|
32518
|
+
yield UNSUPPORTED_INTERACTION_WARNING;
|
|
32510
32519
|
continue;
|
|
32511
32520
|
}
|
|
32512
32521
|
const { method, path, query } = interaction.request;
|
|
@@ -32554,10 +32563,15 @@ class Comparator {
|
|
|
32554
32563
|
yield* compareResHeader(this.#ajvCoerce, route, interaction, index, this.#config);
|
|
32555
32564
|
yield* compareResBody(this.#ajvNocoerce, route, interaction, index, this.#config);
|
|
32556
32565
|
}
|
|
32566
|
+
if (parsedPact.messages) {
|
|
32567
|
+
for (const [_message] of parsedPact.messages.entries()) {
|
|
32568
|
+
yield UNSUPPORTED_INTERACTION_WARNING;
|
|
32569
|
+
}
|
|
32570
|
+
}
|
|
32557
32571
|
}
|
|
32558
32572
|
}
|
|
32559
32573
|
|
|
32560
|
-
var version = "1.
|
|
32574
|
+
var version = "1.8.0";
|
|
32561
32575
|
var packageJson = {
|
|
32562
32576
|
version: version};
|
|
32563
32577
|
|