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

Add CoverageJSON TypeAdapter to support generic loading of CoverageJSON #17

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

PaulVanSchayck
Copy link
Collaborator

@PaulVanSchayck PaulVanSchayck commented Jul 5, 2024

This add support for a generic CoverageJSON type which you can use to validate any JSON against. It implements the root types that can form a CoverageJSON, as defined in the spec.

I've considered (and tested) the implementations listed in this detailed SO answer. In the end I've chosen for Option A.

Option B (Custom Root Type): Very noisy implementation, and forgetting your dealing with a proxy object. It's also not easy to use for validation purposes.

Option C (Union field + proxy constructor): The fake class (as function) is not very clean. It's also not easy use for validation.

For the (lightweight) purpose of validation, Option A seems to be the cleanest to use.

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.

1 participant