-
Notifications
You must be signed in to change notification settings - Fork 26
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
Migrate manifest schema checking into API #160
Comments
from typing import Any, Tuple
from os.path import join, dirname, realpath
from json import load
from jsonschema import validate
from jsonschema.exceptions import ValidationError
__all__ = ["get_election_description_schema", "validate_json_schema"]
def _load_schema(json_schema_file_name: str) -> Any:
"""Loads the given schema"""
with open(join(dirname(realpath(__file__)), json_schema_file_name), "r") as file:
schema = load(file)
return schema
def get_election_description_schema() -> Any:
"""Get default schema for election description schema"""
return _load_schema("election_description_schema.json")
def validate_json_schema(
json_data: Any,
json_schema: Any,
) -> Tuple[bool, str]:
"""Validate json schema"""
try:
validate(instance=json_data, schema=json_schema)
except ValidationError as err:
return (False, err.message)
return (True, "Json schema validated") |
Hey @keithrfung |
Hey @keithrfung, is this issue available I would like to work on it. |
@bhushan-borole and @PradyumnaKrishna Sorry I missed both of these. The schemas are currently in the process of being moved to the github.com/microsoft/electionguard repositories. The idea is that there should be some schemas readily available at that level that can be used in the API to ensure the models are correct. It would likely be wiser to help at that level first. However, this issue is still stands if either of you would like to work. |
Feature Request
Is your feature request related to a problem? Please describe.
These should get moved into to the electionguard-python-api
https://github.com/microsoft/electionguard-python/blob/6d70f6602746bfcf840b59ce986f2c76c5fe58e5/src/electionguard/election_description_schema.json
https://github.com/microsoft/electionguard-python/blob/6d70f6602746bfcf840b59ce986f2c76c5fe58e5/src/electionguard/schema.py
Ideally with a
schema
folder. These could then be moved toelectionguard
root at a later point.Accompanying PR to remove schema checking at base level.
Accompany issue: Election-Tech-Initiative/electionguard-python#384
The text was updated successfully, but these errors were encountered: