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

[Get Familiar] Add schema validation for template configuration #43

Closed
Udayraj123 opened this issue Sep 29, 2022 · 8 comments
Closed

[Get Familiar] Add schema validation for template configuration #43

Udayraj123 opened this issue Sep 29, 2022 · 8 comments
Assignees

Comments

@Udayraj123
Copy link
Owner

Udayraj123 commented Sep 29, 2022

Right now, OMRChecker does not handle invalid template.json files. It simply tries to process the file and throws an errors.

We want to extend that an do a json schema validation for the file.

Steps:

  1. Study current structure of the Template file
  2. Create a json schema for the same.
  3. Use python-jsonschema or similar library to throw validation errors when the input file doesn't match with the schema.

Resources:

  1. https://python-jsonschema.readthedocs.io/en/stable/
  2. https://github.com/python-jsonschema/jsonschema
  3. https://github.com/Udayraj123/OMRChecker/wiki/About-Templates
  4. https://github.com/Udayraj123/OMRChecker/wiki/User-Guide

Note: this issue is marked with the hacktoberfest label. Follow #hacktoberfest-discussions on Discord for further details .

@Udayraj123 Udayraj123 added bug Something isn't working enhancement New feature or request hacktoberfest up-for-grabs intermediate and removed enhancement New feature or request labels Sep 29, 2022
@SpyzzVVarun
Copy link
Contributor

Hi @Udayraj123 , should the schema be created exactly for the template file mentioned here: Template File ?

@Udayraj123
Copy link
Owner Author

That's correct. The same schema can also be found for all template.json files in samples folder

@SpyzzVVarun
Copy link
Contributor

SpyzzVVarun commented Oct 3, 2022

Would it be possible to get an example of an incorrect template file, I did write some code for the validation schema and error handling, but I'm not sure about the constraints to be put in my schema. Also, when I tried setting the dimensions in the sample template to 3, I expected an error but the code seemed to run fine. So, it would be helpful to know the expected constraints.

@Udayraj123
Copy link
Owner Author

You can create incorrect template.json files by removing some of the mandatory keys, or changing their camelCase to TitleCase for keys(in which case validation error should mention that).
Setting 3rd dimension worked as code can run fine because it is written gracefully. Still we need the validation error to be thrown as a caution for future changes.

@SpyzzVVarun
Copy link
Contributor

Have generated a draft PR, do let me know if this is what you were expecting.

@Udayraj123
Copy link
Owner Author

@SpyzzVVarun discussed on discord. Let me know once all changes done..

@Udayraj123
Copy link
Owner Author

Merged #60

@Udayraj123
Copy link
Owner Author

extended in #65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants