-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
There was a problem hiding this 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
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 isgrout-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.