Skip to content

Validate deep payload schemas for every resource - #44

Merged
turegjorup merged 2 commits into
developfrom
test/deep-payload-contract-schemas
Jul 8, 2026
Merged

Validate deep payload schemas for every resource#44
turegjorup merged 2 commits into
developfrom
test/deep-payload-contract-schemas

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

Adds deep JSON-Schema validation of every resource's nested payload, closing the last big contract gap before the API Platform upgrade.

Changes

  • tests/schemas/contract.schema.json — a hand-authored, additive-tolerant schema pinning the nested payload of each resource: organizer/partners, location (incl. coordinates as a 2-number array), occurrences[]/dailyOccurrences[], imageUrls, and the tag/vocabulary item shapes. Types and consumer-critical required fields are declared; additionalProperties stays open.
  • ContractSchemaTest validates both collection members and item endpoints against the schema, handling the D6 quirk (the five nested resources return a hydra:Collection with a single member on their item endpoint; Tag/Vocabulary return true items).
  • Adds justinrainbow/json-schema as a dev dependency (was already present transitively; now an explicit dev requirement).

Why

CollectionContractTest only pins the top-level member field set, and API Platform's self-generated item/collection schema is near-empty (@id/@type/@context only). Neither catches a nested field being removed, renamed, or having its type changed. This schema does — verified: renaming organizer.email, changing entityId to a string, or truncating coordinates all fail; adding a field passes. Tests only — no production code changes.

Add tests/schemas/contract.schema.json — a hand-authored, additive-tolerant
JSON Schema pinning the nested payload of every resource (organizer,
location.coordinates, occurrences[], imageUrls, …) with types and the
consumer-critical required fields. ContractSchemaTest validates both
collection members and item endpoints against it, handling the D6 quirk
where the five nested resources return a hydra:Collection with a single
member on their item endpoint while Tag/Vocabulary return true items.

This is the delta over CollectionContractTest (top-level field set only):
a removed/renamed nested field or a changed type now fails CI, while
adding a field passes. Adds justinrainbow/json-schema as a dev dependency.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.99%. Comparing base (d6f37ac) to head (826c50e).
⚠️ Report is 16 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop      #44      +/-   ##
=============================================
+ Coverage      71.89%   72.99%   +1.09%     
- Complexity       226      232       +6     
=============================================
  Files             29       29              
  Lines            637      648      +11     
=============================================
+ Hits             458      473      +15     
+ Misses           179      175       -4     
Flag Coverage Δ
unittests 72.99% <ø> (+1.09%) ⬆️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@turegjorup turegjorup self-assigned this Jul 8, 2026
@turegjorup
turegjorup merged commit 2677e6d into develop Jul 8, 2026
12 checks passed
@turegjorup
turegjorup deleted the test/deep-payload-contract-schemas branch July 8, 2026 11:36
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.

2 participants