@pactflow/openapi-pact-comparator 1.8.0 → 1.8.1

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 CHANGED
@@ -27592,7 +27592,7 @@ var Ajv$1 = /*@__PURE__*/getDefaultExportFromCjs(ajvExports);
27592
27592
  // a full schema can be found at https://github.com/pactflow/pact-schemas
27593
27593
  // but we don't use that here, because we try to be permissive with input
27594
27594
  const Interaction = Type.Object({
27595
- _skip: Type.Optional(Type.Boolean()),
27595
+ _nonHTTP: Type.Optional(Type.Boolean()),
27596
27596
  type: Type.Optional(Type.String()),
27597
27597
  description: Type.Optional(Type.String()),
27598
27598
  providerState: Type.Optional(Type.String()),
@@ -27622,6 +27622,10 @@ const Interaction = Type.Object({
27622
27622
  status: Type.Number(),
27623
27623
  }),
27624
27624
  });
27625
+ const Message = Type.Object({
27626
+ description: Type.Optional(Type.String()),
27627
+ providerState: Type.Optional(Type.String()),
27628
+ });
27625
27629
  const Pact = Type.Object({
27626
27630
  metadata: Type.Optional(Type.Object({
27627
27631
  pactSpecification: Type.Optional(Type.Object({
@@ -27633,7 +27637,7 @@ const Pact = Type.Object({
27633
27637
  })),
27634
27638
  })),
27635
27639
  interactions: Type.Optional(Type.Array(Interaction)),
27636
- messages: Type.Optional(Type.Array(Type.Unknown())),
27640
+ messages: Type.Optional(Type.Array(Message)),
27637
27641
  });
27638
27642
  const supportedInteractions = (i) => !i.type || i.type.toLowerCase() === "synchronous/http";
27639
27643
  const parseAsPactV4Body = (body) => {
@@ -27704,6 +27708,10 @@ const interactionV4 = (i) => ({
27704
27708
  headers: flattenValues(i.response.headers),
27705
27709
  },
27706
27710
  });
27711
+ const interactionNonHTTP = (i) => ({
27712
+ ...i,
27713
+ _nonHTTP: true,
27714
+ });
27707
27715
  const ajv = new Ajv$1();
27708
27716
  const validate = ajv.compile(Pact);
27709
27717
  const parse = (pact) => {
@@ -27723,9 +27731,7 @@ const parse = (pact) => {
27723
27731
  const interactionParser = version >= 4 ? interactionV4 : version >= 3 ? interactionV3 : interactionV1;
27724
27732
  return {
27725
27733
  metadata,
27726
- interactions: interactions?.map((i) => supportedInteractions(i)
27727
- ? interactionParser(i)
27728
- : { _skip: true }),
27734
+ interactions: interactions?.map((i) => supportedInteractions(i) ? interactionParser(i) : interactionNonHTTP(i)),
27729
27735
  messages,
27730
27736
  };
27731
27737
  };
@@ -32508,14 +32514,18 @@ class Comparator {
32508
32514
  }
32509
32515
  const parsedPact = parse(pact);
32510
32516
  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
32517
  for (const [index, interaction] of parsedInteractions.entries()) {
32517
- if (interaction._skip) {
32518
- yield UNSUPPORTED_INTERACTION_WARNING;
32518
+ if (interaction._nonHTTP) {
32519
+ yield {
32520
+ code: "interaction.type.unsupported",
32521
+ mockDetails: {
32522
+ ...baseMockDetails(interaction),
32523
+ location: `[root].interactions[${index}].type`,
32524
+ value: interaction.type,
32525
+ },
32526
+ message: `Non-HTTP messages cannot be verified against an HTTP-only OpenAPI Document.`,
32527
+ type: "warning",
32528
+ };
32519
32529
  continue;
32520
32530
  }
32521
32531
  const { method, path, query } = interaction.request;
@@ -32564,14 +32574,24 @@ class Comparator {
32564
32574
  yield* compareResBody(this.#ajvNocoerce, route, interaction, index, this.#config);
32565
32575
  }
32566
32576
  if (parsedPact.messages) {
32567
- for (const [_message] of parsedPact.messages.entries()) {
32568
- yield UNSUPPORTED_INTERACTION_WARNING;
32577
+ for (const [index, message] of parsedPact.messages.entries()) {
32578
+ yield {
32579
+ code: "interaction.type.unsupported",
32580
+ mockDetails: {
32581
+ interactionDescription: message.description,
32582
+ interactionState: message.providerState || "[none]",
32583
+ location: `[root].messages[${index}]`,
32584
+ value: message,
32585
+ },
32586
+ message: `Non-HTTP messages cannot be verified against an HTTP-only OpenAPI Document.`,
32587
+ type: "warning",
32588
+ };
32569
32589
  }
32570
32590
  }
32571
32591
  }
32572
32592
  }
32573
32593
 
32574
- var version = "1.8.0";
32594
+ var version = "1.8.1";
32575
32595
  var packageJson = {
32576
32596
  version: version};
32577
32597