json-yaml-validate
json-yaml-validate copied to clipboard
Feature: Support Multiple Schemas
Feature: Support Multiple Schemas
This issue tracks work related to supporting multiple features in this Action. It has been brought to my attention (https://github.com/GrantBirki/json-yaml-validate/issues/6) that users are looking for a way to validate multiple files with multiple schemas.
Success Criteria:
- Allow multiple schemas to be 'inputted' into this Action
- Add a mapping of schema -> file so that the correct files are validated with the correct schemas
- Update tests to support this use case
Cool. I think selecting json files explicity via input is the right way. I don't want all json files to be checked and I have different schemas for each file I want to be checked. Just sharing a real-life use case ;)
Has this been actioned upon yet? Currently hit a road block with this action because I'm specifying one single file and it's attempting to validate everything.
@andy-lawler-sbg It has not been completed yet. I have to prioritize other work at the moment and I'm not able to add this change. Pull requests are welcome though!
That being said, there are a couple of ways around this. You can tweak the inputs of this Action (either through the base_dir
or one of the "exclude" options) to only validate or run against specific files. Then you could have a second (or more) workflows running with different schemas and pointing at different files that use said schemas. Its not pretty but it is a work around until this feature is added.
@GrantBirki Adding the options json_include_regex
and yaml_include_regex
as a first step would also really help, especially if your JSON files are all in the same directory and if you have multiple schemas (so your json_exclude_regex
becomes (too) complex).
Then you could do the following:
jobs:
validate-json:
name: Validate JSONs
steps:
- uses: actions/checkout@v4
- name: Validate index JSON files
id: index-json-validate
uses: GrantBirki/[email protected]
with:
json_schema: ./schemas/index-schema.json
base_dir: ./data
# Validate files with prefix index_ and suffix .json
json_include_regex: 'index_.*\.json$'
- name: Validate topic JSON files
id: topic-json-validate
uses: GrantBirki/[email protected]
with:
json_schema: ./schemas/topic-schema.json
base_dir: ./data
# Validate files with prefix topic_ and suffix .json
json_include_regex: 'topic_.*\.json$'