Skip to content

Migrate manifest schema checking into API #160

Open

Description

@keithrfung

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 to electionguard root at a later point.

Accompanying PR to remove schema checking at base level.

Accompany issue: Election-Tech-Initiative/electionguard-python#384

Activity

  1. keithrfung commented on Jul 21, 2021

    @keithrfung
    ContributorAuthor
    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")
  2. bhushan-borole commented on Jul 29, 2021

    @bhushan-borole

    Hey @keithrfung
    I would like to take up this issue.
    As far as I have understood the description, those two files have to be moved into the api project under schema folder correct?
    But what is the above code that you have given?

  3. PradyumnaKrishna commented on Oct 3, 2021

    @PradyumnaKrishna

    Hey @keithrfung, is this issue available I would like to work on it.

  4. keithrfung commented on Oct 6, 2021

    @keithrfung
    ContributorAuthor

    @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.
    The issue is about making a method to check the schema after a post is made to the call to check a manifest. The schema check itself is getting entirely removed from the bottom python level.

  5. changed the title [-]Schema checking of manifest should exist here[/-] [+]Migrate manifest schema checking into within the API itself[/+] on Oct 8, 2021
  6. changed the title [-]Migrate manifest schema checking into within the API itself[/-] [+]Migrate manifest schema checking into API[/+] on Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions