RubySchema is a collection of JSON schemas for common Ruby gem configuration files. These schemas enable auto-complete, validation, and inline documentation in editors via the YAML language server. Schemas are committed directly to the dist/ folder and deployed to Cloudflare at https://www.rubyschema.org/.
- All schemas use JSON Schema draft-07 (
https://json-schema.org/draft-07/schema#), since that's what the YAML language server supports. - Every schema must include a
$schemaand$idfield. The$idshould behttps://www.rubyschema.org/<name>.json. - Use
markdownDescription(notdescription) for documentation strings — this is what editors render. - Include
default,examples, andtypewhere appropriate. - Use
definitionsfor reusable sub-schemas and reference them with$ref. - Schemas should only be created for project-level configuration files, not global/user-level configs (e.g.
~/.yard/configwould not belong here).
dist/— JSON schema files and therails.rbtemplate. This is the deployed directory.dist/rails.rb— A Rails app template that injects schema comments into project config files. Schemas added here must correspond to files that live within a Rails project directory (paths start with./).test/fixtures/— Example config files organised by gem name, used for testing schemas.
- Create the schema as
dist/<name>.json(ordist/<name>/<subname>.jsonfor namespaced schemas). - If the config file lives inside a Rails project, add a mapping entry to the appropriate hash in
dist/rails.rb(yaml_schemas,json_schemas, ortoml_schemas). Keep entries in alphabetical order by path. - Add test fixtures under
test/fixtures/<name>/.
Tests use Minitest and validate every schema against JSON Schema draft-07 and check that all fixture files pass validation against their corresponding schema.
bundle exec rake testThis runs all tests in test/. You can also run a single test file directly:
bundle exec ruby test/schema_test.rb- Ruby code follows Rubocop with the configuration in
.rubocop.yml(inherits fromhttps://www.goodcop.style/base.yml), targeting Ruby 3.4. - JSON schemas should be formatted with 2-space indentation.