{"id":46504608,"url":"https://github.com/yaml-schema/yaml-schema","last_synced_at":"2026-04-01T22:24:36.409Z","repository":{"id":242986318,"uuid":"807908635","full_name":"yaml-schema/yaml-schema","owner":"yaml-schema","description":"Validate YAML documents using a YAML schema","archived":false,"fork":false,"pushed_at":"2026-03-21T15:38:30.000Z","size":925,"stargazers_count":24,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-21T16:13:18.304Z","etag":null,"topics":["rust","yaml","yaml-validator"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yaml-schema.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2024-05-30T02:26:38.000Z","updated_at":"2026-03-21T15:38:33.000Z","dependencies_parsed_at":"2024-06-29T03:40:43.352Z","dependency_job_id":"b2d79c66-0a8d-403c-a270-8554f1e47efd","html_url":"https://github.com/yaml-schema/yaml-schema","commit_stats":null,"previous_names":["aisrael/yaml-schema","yaml-schema/yaml-schema"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/yaml-schema/yaml-schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaml-schema%2Fyaml-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaml-schema%2Fyaml-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaml-schema%2Fyaml-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaml-schema%2Fyaml-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaml-schema","download_url":"https://codeload.github.com/yaml-schema/yaml-schema/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaml-schema%2Fyaml-schema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rust","yaml","yaml-validator"],"created_at":"2026-03-06T14:31:42.037Z","updated_at":"2026-04-01T22:24:36.402Z","avatar_url":"https://github.com/yaml-schema.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"ys - yaml-schema\n====\n\n[![CI Tests](https://github.com/aisrael/yaml-schema/actions/workflows/ci-tests.yaml/badge.svg)](https://github.com/aisrael/yaml-schema/actions/workflows/ci-tests.yaml)\n\n**yaml-schema** is a tool to validate YAML files against a YAML schema.\n\nThe YAML Schema specification is based on JSON Schema ([https://json-schema.org/](https://json-schema.org/)), but\nexpressed as YAML.\n\n**yaml-schema** is both a Rust library _and_ an executable.\n\n## Example Usage\n\nGiven a `schema.yaml` file containing:\n\n```\ntype: object\nproperties:\n  foo:\n    type: string\n  bar:\n    type: number\n```\n\nAnd a `valid.yaml` file containing:\n\n```\nfoo: \"I'm a string\"\nbar: 42\n```\n\nThen when you issue the command\n\n```\nys -f schema.yaml valid.yaml\n```\n\nThen the command should succeed with exit code 0\n\nOn the other hand, when given an `invalid.yaml` file containing:\n\n```\nfoo: 42\nbar: \"I'm a string\"\n```\n\nThen the command\n\n```\nys -f schema.yaml invalid.yaml\n```\n\nShould fail with exit code 1\n\n## JSON Output\n\nPass `--json` to emit structured errors instead of plain text. Use it with the same options as usual.\n\n**Successful validation** (exit code `0`): stdout is empty.\n\n```\nys --json -f schema.yaml valid.yaml\n```\n\n(no output on stdout)\n\n**Validation failures** (exit code `1`): stdout is a single JSON **array** of objects, one per error. Each object has:\n\n| Field   | Meaning |\n|--------|---------|\n| `index` | Byte offset into the source, or `null` if unknown |\n| `line`  | 1-based line number, or `null` if unknown |\n| `col`   | 0-based column index from the parser, or `null` if unknown |\n| `path`  | Dot-separated path from the document root (e.g. `foo`, `items.0`) |\n| `error` | Human-readable message |\n\nUsing the same `schema.yaml` / `invalid.yaml` scenario as [above](#example-usage), with `foo` and `bar` violating their types:\n\n```sh\nys --json -f schema.yaml invalid.yaml\n```\n\nstdout (pretty-printed; the tool emits compact JSON on one line):\n\n```json\n[\n  {\n    \"col\": 5,\n    \"error\": \"Expected a string, but got: 42 (int)\",\n    \"index\": 5,\n    \"line\": 1,\n    \"path\": \"foo\"\n  },\n  {\n    \"col\": 5,\n    \"error\": \"Expected a number, but got: \\\"I'm a string\\\" (string)\",\n    \"index\": 13,\n    \"line\": 2,\n    \"path\": \"bar\"\n  }\n]\n```\n\n**Other failures** (exit code `1`): schema load errors, missing arguments, YAML parse errors, and similar issues print a single JSON object on **stderr**: `{\"error\":\"\u003cmessage\u003e\"}`.\n\nIf the schema file cannot be read:\n\n```sh\nys --json -f /path/to/missing-schema.yaml valid.yaml\n```\n\nstderr:\n\n```json\n{\"error\":\"Failed to read YAML schema file /path/to/missing-schema.yaml: No such file or directory (os error 2)\"}\n```\n\nThe exact `error` text depends on the failure (OS messages, parse errors, etc.).\n\nValidation errors are written to **stdout**; non-validation errors use **stderr**, so callers can distinguish validation results from tooling or I/O failures.\n\n\n## Features\n\n**yaml-schema** uses [Cucumber](https://cucumber-rs.github.io/cucumber/main/) to specify and test features:\n\n- [CLI usage](features/cli.feature)\n- [Basic features](features/basics.feature)\n- [String validation](features/validation/strings.feature)\n- [Numeric types](features/validation/numbers.feature)\n- [Const](features/validation/const.feature)\n- [Enums](features/validation/enums.feature)\n- [Object types](features/validation/objects.feature)\n- [Arrays](features/validation/arrays.feature)\n- [Composition](features/composition.feature)\n- [Unevaluated properties/items](features/validation/unevaluated.feature)\n\nSee the [features](features/) folder for all examples.\n\n## Installation\n\nCurrently, **yaml-schema** requires Git, Rust and Cargo to build and\ninstall: [https://doc.rust-lang.org/cargo/](https://doc.rust-lang.org/cargo/)\n\nTo install the stable release from [crates.io](https://crates.io/crates/yaml-schema):\n\n```\ncargo install yaml-schema\n```\n\nThat should build and install the executable at `$HOME/.cargo/bin/ys` (which should be in your PATH)\n\nAlternatively, one can install from latest source:\n\n```\ncargo install --git https://github.com/yaml-schema/yaml-schema\n```\n\n## Usage\n\nRunning `ys` without any options or arguments should display the help:\n\n```\nA tool for validating YAML against a schema\n\nUsage: ys [OPTIONS] [FILE] [COMMAND]\n\nCommands:\n  version  Display the ys version\n  help     Print this message or the help of the given subcommand(s)\n\nArguments:\n  [FILE]  The YAML file to validate\n\nOptions:\n  -f, --schema \u003cSCHEMAS\u003e  The schema to validate against\n      --fail-fast         Specify this flag to exit (1) as soon as any error is encountered\n  -h, --help              Print help\n  -V, --version           Print version\n  ```\n\n## Self-Validation\n\n**yaml-schema** is _self-validating_. That is, running\n\n```\ncargo run -- -f yaml-schema.yaml yaml-schema.yaml\n```\n\n_should_ always succeed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaml-schema%2Fyaml-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaml-schema%2Fyaml-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaml-schema%2Fyaml-schema/lists"}