GrantBirki / json-yaml-validate

A GitHub Action to quickly validate JSON and YAML files in a repository
MIT License
28 stars 11 forks source link

Feature request: Add draft-04 schema support #68

Closed kirpichyov closed 2 months ago

kirpichyov commented 3 months ago

Hi! I am trying to use action to verify the API doc file which follows the OpenAPI 3.0.1 schema (Schema reference).

      - name: Verify api-doc.json
        uses: GrantBirki/json-yaml-validate@v3.0.0
        with:
          mode: "fail"
          comment: "true"
          files: "api-doc.json"
          json_schema: "./schemas/open-api-3_0.json"
          json_schema_version: "draft-04"

But it gives an error:

Warning: json_schema_version 'draft-04' is not supported. Defaulting to 'draft-07'

/home/runner/work/_actions/GrantBirki/json-yaml-validate/v3.0.0/node_modules/ajv/dist/core.js:147
                throw new Error(`no schema with key or ref "${schemaKeyRef}"`);

So it looks like OpenAPI 3.0.1 use draft-04 json schema which is supported by Ajv according to the documentation but not supported by the json-yaml-validate. I have tried to use other schemas in the json_schema_version like draft-07 but it doesn't work. It would be great and very appreciable to add support for draft-04 for the json_schema_version parameter.

GrantBirki commented 2 months ago

This does appear to be possible and something I can work on in the future: https://github.com/ajv-validator/ajv-draft-04

GrantBirki commented 2 months ago

@kirpichyov I have published a pre-release -> v3.2.0. Would you be able to try this out and see if it works for your use case and let me know how it goes? Thanks! 🙇

kirpichyov commented 2 months ago

It works now, thanks!