8000 GitHub - LeipeLeon/rubyschema
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

LeipeLeon/rubyschema

 
 

Repository files navigation

Ruby Schema

YAML is an incredibly difficult language for me. Between significant whitespace, bare strings and ambiguous booleans, I find it quite impossible to follow. And although the language has improved over time, 15 years since the v1.2 spec was released, Ruby is still stuck on the 1.1 spec.

Most YAML configs need to be just so in order to work properly yet they are often unspecified, poorly documented and lack proper validation.

Despite all this, YAML is the primary language for Ruby Gem configs and there’s nothing you or I can do about it.

The good news is, modern text editors support language servers and there’s a fantastic language server for YAML files. All we need to do is tell the language server which version of YAML we’re using (1.1) and give it a data schema.

Ruby schema is a collection of JSON schemas for common Ruby gems. With these schemas, we can now enjoy auto-complete, validation and inline documentation right in our YAML files.

Example of auto-complete

Rails

To install all the Ruby schemas in a Rails, you can run:

bundle exec rails app:template LOCATION=https://www.rubyschema.org/rails.rb

You can run it again for updates as new schemas are released.

database.yml

# yaml-language-server: $schema=https://www.rubyschema.org/rails/database.json

%YAML 1.1
---

storage.yml

# yaml-language-server: $schema=https://www.rubyschema.org/rails/storage.json

%YAML 1.1
---

recurring.yml

# yaml-language-server: $schema=https://www.rubyschema.org/rails/recurring.json

%YAML 1.1
---

queue.yml

Planned

cache.yml

# yaml-language-server: $schema=https://www.rubyschema.org/rails/cache.json

%YAML 1.1
---

cable.yml

# yaml-language-server: $schema=https://www.rubyschema.org/rails/cable.json

%YAML 1.1
---

Rubocop

rubocop.yml

# yaml-language-server: $schema=https://www.rubyschema.org/rubocop.json

%YAML 1.1
---

Vite

vite.json

{
  "$schema": "https://www.rubyschema.org/vite.json"
}

Kamal

deploy.yml

# yaml-language-server: $schema=https://www.rubyschema.org/kamal/deploy.json

%YAML 1.1
---

I18n

locales/{language}.yml

# yaml-language-server: $schema=https://www.rubyschema.org/i18n/locale.json

%YAML 1.1
---

Sidekiq

sidekiq.yml

# yaml-language-server: $schema=https://www.rubyschema.org/sidekiq.json

%YAML 1.1
---

RoRvsWild

rorvswild.yml

# yaml-language-server: $schema=https://www.rubyschema.org/rorvswild.json

%YAML 1.1
---

Standard

standard.yml

# yaml-language-server: $schema=https://www.rubyschema.org/standard.json

%YAML 1.1
---

Honeybadger

honeybadger.yml

# yaml-language-server: $schema=https://www.rubyschema.org/honeybadger.json

%YAML 1.1
---

Shoryuken

shoryuken.yml

# yaml-language-server: $schema=https://www.rubyschema.org/shoryuken.json

%YAML 1.1
---

Packwerk

package.yml

# yaml-language-server: $schema=https://www.rubyschema.org/packwerk/package.json

%YAML 1.1
---

Lefthook

lefthook.yml

# yaml-language-server: $schema=https://www.rubyschema.org/lefthook.json

%YAML 1.1
---

lefthook.json

{
  "$schema": "https://www.rubyschema.org/lefthook.json"
}

lefthook.toml

#:schema https://www.rubyschema.org/lefthook.json

Scout AMP

scout_apm.yml

# yaml-language-server: $schema=https://www.rubyschema.org/scout_apm.json

%YAML 1.1
---

Mongoid

mongoid.yml

# yaml-language-server: $schema=https://www.rubyschema.org/mongoid.json

%YAML 1.1
---

Pghero

pghero.yml

# yaml-language-server: $schema=https://www.rubyschema.org/pghero.json

%YAML 1.1
---

I18n-tasks

i18n-tasks.yml

# yaml-language-server: $schema=https://www.rubyschema.org/i18n-tasks.json

%YAML 1.1
---

Contributing

If you find an issue with a schema, for example it says that something is invalid when it isn’t, please open an issue with an example.

The schemas are written in JSON Schema version 7 (since that’s the version that YAML LSP supports). They are currently committed directly to the dist folder, which is deployed automatically to Cloudflare.

You can test the schemas locally by replacing the $schema URL with a relative path. In Zed, you need to run the editor: restart language server command each time you make changes to the schema.

Why is it called RubySchema?

I know it’s confusing. RubySchema provides JSON Schemas for YAML files. 🤯 The name reflects the purpose of providing schemas specifically for the Ruby community, where a lot of Ruby gems rely on YAML/JSON configuration files. There’s another project called JSON Schema Store with a significantly wider scope.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%
0