{"id":21956966,"url":"https://github.com/lesomnus/cray","last_synced_at":"2026-04-16T10:01:38.922Z","repository":{"id":89493374,"uuid":"581877299","full_name":"lesomnus/cray","owner":"lesomnus","description":"Schema description framework","archived":false,"fork":false,"pushed_at":"2023-01-07T13:44:11.000Z","size":247,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T18:23:57.016Z","etag":null,"topics":["json","json-schema","schema-generator","validator","yaml"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lesomnus.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}},"created_at":"2022-12-24T17:31:31.000Z","updated_at":"2025-06-14T19:44:32.000Z","dependencies_parsed_at":"2024-06-29T09:51:13.195Z","dependency_job_id":null,"html_url":"https://github.com/lesomnus/cray","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lesomnus/cray","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesomnus%2Fcray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesomnus%2Fcray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesomnus%2Fcray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesomnus%2Fcray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lesomnus","download_url":"https://codeload.github.com/lesomnus/cray/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesomnus%2Fcray/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31880882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T09:23:21.276Z","status":"ssl_error","status_checked_at":"2026-04-16T09:23:15.028Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["json","json-schema","schema-generator","validator","yaml"],"created_at":"2024-11-29T08:41:32.210Z","updated_at":"2026-04-16T10:01:38.879Z","avatar_url":"https://github.com/lesomnus.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CRay\n\n[![test](https://github.com/lesomnus/cray/actions/workflows/test.yaml/badge.svg)](https://github.com/lesomnus/cray/actions/workflows/test.yaml)\n[![codecov](https://codecov.io/gh/lesomnus/cray/branch/main/graph/badge.svg?token=Zw14Luij1P)](https://codecov.io/gh/lesomnus/cray)\n\nAccess configs in a structured manner with validation and automatically generate documented configs.\n\nCRay creates a schema for your data by tracking how you access it. You don't have to keep checking each value in the middle of your code to see if it satisfies the condition you want. Validate documents at once with an automatically generated schema, and see at a glance what values went wrong.\n\n\n\n## Support\n\n### Loaders\n\n- YAML (powered by [jbeder/yaml-cpp](https://github.com/jbeder/yaml-cpp))\n\n### Reporters\n\n- YAML\n- JSON Schema\n\n\n\n## CMake Integration\n```cmake\ninclude(FetchContent)\nFetchContent_Declare(\n  CRay\n  GIT_REPOSITORY https://github.com/lesomnus/cray.git\n  GIT_TAG        main\n)\nFetchContent_MakeAvailable(CRay)\n\n...\n\nadd_library(foo ...)\n...\ntarget_link_libraries(\n\tfoo PRIVATE\n\t\tCRay::CRay\n\t\tCRay::yaml  # YAML loader support\n)\n```\n\nNote that `CRay::yaml` is enabled only if the `yaml-cpp` package is available.\n\n\n## Example\n\nYou may want to read what kind of [describers](docs/describers.md) are available.\n\n```cpp\n#include \u003cfstream\u003e\n#include \u003ciostream\u003e\n#include \u003coptional\u003e\n#include \u003csstream\u003e\n#include \u003cstring\u003e\n\n#include \u003ccray.hpp\u003e\n\nstruct Step {\n\tstd::string name;\n\tstd::string run;\n};\n\nstruct Job {\n\tstd::vector\u003cstd::string\u003e runs_on;\n\tstd::vector\u003cStep\u003e        steps;\n};\n\nint main(int argc, char*[] argv) {\n\tusing namespace cray;\n\t\n\tNode doc(load::fromYaml(\"workflow.yaml\"));\n\n\tauto const name = doc[\"name\"].as\u003cstd::string\u003e(Annotation{\n\t    .title       = \"Name\",\n\t    .description = \"The name of your workflow.\",\n\t});\n\n\tauto const run_name = doc[\"run-name\"].as\u003cstd::optional\u003cstd::string\u003e\u003e(Annotation{\n\t    .title       = \"Run Name\",\n\t    .description = \"The name for workflow runs generated from the workflow.\",\n\t});\n\n\tauto events = prop\u003cType::Str\u003e().oneOf({\n\t    \"push\",\n\t    \"pull_request\",\n\t    \"workflow_dispatch\",\n\t});\n\n\tauto const on = doc[\"on\"].is\u003cType::List\u003e().of(events).get();\n\n\tauto step =\n\t    prop\u003cType::Map\u003e().to\u003cStep\u003e()\n\t    | field(\"name\", \u0026Step::name)\n\t    | field(\"run\", \u0026Step::run);\n\n\tauto job =\n\t    prop\u003cType::Map\u003e().to\u003cJob\u003e()\n\t    | field(\"runs-on\", \u0026Job::runs_on)\n\t    | field(\"steps\", \u0026Job::steps, step);\n\n\tauto const jobs = doc[\"jobs\"].is\u003cType::Map\u003e().of(job).get();\n\n\tstd::ofstream out(\"workflow.yaml\");\n\treport::asYaml(out, doc);\n\t\n\tstd::ofstream out(\"workflow.schema.json\");\n\treport::asJsonSchema(out, doc);\n\n\tif(!doc.ok()){\n\t\t// There is a field that does not satisfy the condition or has the wrong type.\n\t\treturn -1;\n\t}\n\n\t// name == \"Test\"\n\t// jobs[\"test\"].steps[0].run == \"build \u0026\u0026 test\"\n\t// ...\n}\n```\n\nConsider original `workflow.yaml`:\n```yaml\nname: Test\non: [push, pull_request]\njobs:\n  test:\n    runs-on: [ubuntu-20.04]\n    steps:\n      - name: Test\n        run: build \u0026\u0026 test\n``` \n\nWill be:\n```yaml\n# Name\n# | The name of your workflow.\nname: Test\n\n# Run Name\n# | The name for workflow runs generated from the workflow.\nrun-name:   # \u003cString\u003e\n\non: \n  # • push | pull_request | workflow_dispatch\n  [push, pull_request]\njobs: \n  test: \n    runs-on: [ubuntu-20.04]\n    steps: \n      - \n        name: Test\n        run: build \u0026\u0026 test\n```\n\nAnd you can have JSON schema `workflow.schema.json`:\n\n\u003e This is a summarized result. Full results can be found at [tests/src/example-report.cpp](tests/src/example-report.cpp).\n\n```json\n{\n\t\"type\": \"object\",\n\t\"required\": [\n\t\t\"name\",\n\t\t\"on\",\n\t\t\"jobs\"\n\t],\n\t\"properties\": {\n\t\t\"name\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"title\": \"Name\",\n\t\t\t\"description\": \"The name of your workflow.\"\n\t\t},\n\t\t\"run-name\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"title\": \"Run Name\",\n\t\t\t\"description\": \"The name for workflow runs generated from the workflow.\"\n\t\t},\n\t\t\"on\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"items\": {\n\t\t\t\t\"type\": \"string\",\n\t\t\t\t\"enum\": [\n\t\t\t\t\t\"push\",\n\t\t\t\t\t\"pull_request\",\n\t\t\t\t\t\"workflow_dispatch\"\n\t\t\t\t]\n\t\t\t}\n\t\t},\n\t\t\"jobs\": {\n\t\t\t...\n\t\t}\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flesomnus%2Fcray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flesomnus%2Fcray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flesomnus%2Fcray/lists"}