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