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

How to validate schema for various files? #6

Closed
djrmarques opened this issue Apr 27, 2023 · 6 comments
Closed

How to validate schema for various files? #6

djrmarques opened this issue Apr 27, 2023 · 6 comments
Labels
question Further information is requested

Comments

@djrmarques
Copy link

For example, if I have the following project structure:

- data/
  - file1.json
  - file2.json
  - another_folder/
    - other_file_1.yaml
    - other_file_2.yaml

How can I setup schema validation?
It seems that the action only let's me specify a single schema validation file, via the json_schema and yaml_schema parameters, but how do I set it up if I have various file across my repo?

Thank you :)

@GrantBirki GrantBirki added the question Further information is requested label Apr 27, 2023
@GrantBirki
Copy link
Owner

Currently, this Action only supports one schema input at a time. So if you had various files (all with different schemas), you would need to call the Action multiple times and ensure you use a new schema each time and only check the file that applies to that schema.

Ideally, a feature would be added to support multiple schemas, and their corresponding file paths to check with each.

@Can-Sahin
Copy link

I honestly think not having this will be a factor for people not using this. I don't know how many projects will have only a single json format they need to validate. I have a couple and writing an action for each is quite ugly ;)

@GrantBirki
Copy link
Owner

Sounds like this is something that we need then! I will be tracking work on this here: #7

cc: @Can-Sahin + @djrmarques

@djrmarques
Copy link
Author

I think it would be nice to implement something like the following.

- data/
  - file1.json
  - file2.json
  - file1.schema.json
  - another_folder/
    - other_file_1.yaml
    - other_file_1.schema.yaml    
    - other_file_2.yaml
    - other_file_2.schema.yaml

This way, the action would allow to define a schema in the same folder as the files.

I can try and make a PR with this depending on how much time I have on the weekend.

@Can-Sahin
Copy link

If you enforce file namings or directory structure to use this action I'm pretty sure nobody will use this action. It's kinda absurd to enforce such a thing :)

List of input json files and map of their schema files is the way to go.

@djrmarques
Copy link
Author

Not enforce, it would be an option. I think this would make sense in some cases, given that you could add schema files without changing the action code. You could give an option for defining the suffix of the files that should be considered schemas.

Anyways, I also agree that your suggestion is a good one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants