Skip to content

A CLI and pre-commit hooks for jsonschema validation in YAML files with multiple documents

License

Notifications You must be signed in to change notification settings

jmlrt/check-yamlschema

Repository files navigation

check-yamlschema

A CLI and pre-commit hook for jsonschema validation in YAML files with multiple documents

Parse multi-documents YAML files, look for inline schema comments, and validate the documents according to their schema.

The inline schema comments should use the following format:

# yaml-language-server: $schema=<schema_url>
food: # Some YAML document
  - vegetables: tomatoes
  - fruits:
      citrics: oranges
      tropical: bananas
      nuts: peanuts
      sweets: raisins
---
# yaml-language-server: $schema=<another_schema_url
name: Martin Devloper # Some other YAML document
age: 26
hobbies:
  - painting
  - playing_music
  - cooking
programming_languages:
  java: Intermediate
  python: Advanced
  javascript: Beginner
favorite_food:
  - vegetables: tomatoes
  - fruits:
      citrics: oranges
      tropical: bananas
      nuts: peanuts
      sweets: raisins

CLI usage

  • Install it with pip install check-yamlschema
  • Run it with some YAML files in parameters: check-yamlschema file1.yaml file2.yaml ...

Pre-commit usage

Add this to your .pre-commit-config.yaml:

  - repo: https://github.com/jmlrt/check-yamlschema
    rev: v0.0.4
    hooks:
      - id: check-yamlschema

About

A CLI and pre-commit hooks for jsonschema validation in YAML files with multiple documents

Resources

License

Stars

Watchers

Forks

Packages

No packages published