Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mrc-6113 JSON schema #6

Merged
merged 14 commits into from
Jan 13, 2025
Merged

mrc-6113 JSON schema #6

merged 14 commits into from
Jan 13, 2025

Conversation

EmmaLRussell
Copy link
Contributor

@EmmaLRussell EmmaLRussell commented Dec 18, 2024

Add JSON Schema for JSON endpoint responses, and validate responses during integration tests.

The main controversy here is how to handle validating both our generic outer response format and the inner data property which changes for each endpoint, without repeating ourselves.

I was hoping to flashily get this working with $dynamicRef, to plug in different data schema into the outer "Response" schema - however I was scuppered by an outstanding bug in Ajv where dynamic refs result in spurious validation errors with "required"s being wrongly applied to the dynamic refs. Could potentially have got this working in hyperjump, but that didn't seem to reliably yield nice validation errors, so it didn't seem worth it...

So instead I'm using $ref - which requires a corresponding $id to match in an available data schema. This works as long as there is only one loaded schema with the relevant $id (which is grout-data). I could have put this $id in all the data schema, but it didn't quite sit right to have duplicate ids in the files themselves, so instead I'm appending the $id to the loaded data schema at runtime in the integration tests.

See the README update for more details on implementation.

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.41%. Comparing base (e31e8fd) to head (18e9203).
Report is 15 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main       #6   +/-   ##
=======================================
  Coverage   98.41%   98.41%           
=======================================
  Files          15       15           
  Lines         126      126           
  Branches       15       15           
=======================================
  Hits          124      124           
  Misses          2        2           

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

@EmmaLRussell EmmaLRussell changed the base branch from mrc-6089-codecov to main January 6, 2025 10:21
@EmmaLRussell EmmaLRussell changed the title mrc-6113 jsonschema and api docs mrc-6113 JSON schema Jan 7, 2025
@EmmaLRussell EmmaLRussell marked this pull request as ready for review January 7, 2025 15:34
Copy link
Contributor

@M-Kusumgar M-Kusumgar left a comment

Choose a reason for hiding this comment

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

Think it turned out pretty clean! shame about the bug though

@EmmaLRussell EmmaLRussell merged commit 2a97d97 into main Jan 13, 2025
4 checks passed
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