Skip to content

Conversation

@JP-Ellis
Copy link
Contributor

📝 Summary

Add an example which showcases how matching rules can be used to validate multipart/form-data payloads.

🚨 Breaking Changes

🔥 Motivation

The multipart/form-data payloads will typically contain additional structure internally. In order to validate this in Pact, this requires setting up matching rules, but in a situation where the typical 'embed the matcher with the value' doesn't work; instead requiring that the with_matching_rules method be called.

This documentation hopefully will help end-users validate these kinds of payloads.

🔨 Test Plan

Documentation is through an example, which is run as part of CI.

🔗 Related issues/PRs

Copilot AI review requested due to automatic review settings November 19, 2025 10:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds documentation and examples for using Pact matching rules with multipart/form-data payloads. The examples demonstrate both consumer and provider tests for validating multipart requests containing JSON metadata and binary image data.

Key changes:

  • Created a new patterns catalog structure with a multipart form-data example
  • Added comprehensive documentation showing how to apply matching rules to individual parts within multipart bodies
  • Included working test implementations for both consumer and provider sides

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
mkdocs.yml Added Pydantic documentation inventory for cross-referencing
examples/catalog/pyproject.toml New project configuration for the catalog examples with required dependencies
examples/catalog/multipart_matching_rules/test_provider.py Provider verification test demonstrating FastAPI server handling multipart uploads
examples/catalog/multipart_matching_rules/test_consumer.py Consumer test showing how to define matching rules for multipart request parts
examples/catalog/multipart_matching_rules/init.py Empty init file for Python package
examples/catalog/multipart_matching_rules/README.md Documentation explaining the multipart matching rules pattern
examples/catalog/init.py Empty init file for catalog package
examples/catalog/README.md Main catalog documentation with usage instructions
examples/README.md Updated to reference the new patterns catalog

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51%. Comparing base (4dc54b3) to head (c494ce3).
⚠️ Report is 19 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@         Coverage Diff          @@
##           main   #1350   +/-   ##
====================================
  Coverage    51%     51%           
====================================
  Files        31      31           
  Lines      3727    3727           
====================================
  Hits       1936    1936           
  Misses     1791    1791           
Flag Coverage Δ
tests 51% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Add an example which showcases how matching rules can be used to
validate multipart/form-data payloads.

Signed-off-by: JP-Ellis <josh@jpellis.me>
@JP-Ellis JP-Ellis force-pushed the docs/add-multipart-formdata branch from dd43092 to c494ce3 Compare November 20, 2025 03:29
@JP-Ellis JP-Ellis merged commit 0dda3f3 into main Dec 2, 2025
59 checks passed
@JP-Ellis JP-Ellis deleted the docs/add-multipart-formdata branch December 2, 2025 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support mixed multipart/form‑data text fields and file parts in one interaction How to combine with_multipart_file with additional body fields?

3 participants