{"id":28865728,"url":"https://github.com/increments/json_schema_view","last_synced_at":"2025-10-18T06:33:04.599Z","repository":{"id":64941057,"uuid":"521086702","full_name":"increments/json_schema_view","owner":"increments","description":"View framework that brings Schema-driven Development to Rails view","archived":false,"fork":false,"pushed_at":"2025-05-23T03:21:38.000Z","size":66,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-23T04:32:17.908Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/increments.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-04T01:42:18.000Z","updated_at":"2025-05-23T03:15:42.000Z","dependencies_parsed_at":"2022-12-19T05:25:45.899Z","dependency_job_id":null,"html_url":"https://github.com/increments/json_schema_view","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/increments/json_schema_view","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/increments%2Fjson_schema_view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/increments%2Fjson_schema_view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/increments%2Fjson_schema_view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/increments%2Fjson_schema_view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/increments","download_url":"https://codeload.github.com/increments/json_schema_view/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/increments%2Fjson_schema_view/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260924521,"owners_count":23083526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-06-20T10:14:32.052Z","updated_at":"2025-10-18T06:33:04.593Z","avatar_url":"https://github.com/increments.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JsonSchemaView\n\nJsonSchemaView is a view framework that brings Schema-driven Development to Rails view and another view frameworks (e.g react_on_rails).\n\nJsonSchemaView is a Ruby object:\n\n```ruby\nclass TodoItemComponent \u003c JsonSchemaView::BaseComponent\n  renderer_class :react_on_rails\n\n  props_class do\n    property :title, type: String\n    property :done, type: [TrueClass, FalseClass]\n\n    attr_reader :title, :done\n\n    def initialize(title:, done:)\n      @title = title\n      @done = done\n    end\n  end\nend\n```\n\nThe component can be passed to Rails' `render` and then its schema validates its props:\n\n```ruby\nrender TodoItemComponent.new(props: { title: 'Buy milk', done: false }) # =\u003e Valid against schema. Renders a view by using renderer (react_on_rails)\n\nrender TodoListComponent.new(props: { title: 'Buy milk', done: \"Invalid value\" }) # =\u003e Invalid. Raises an error.\n```\n\nThe component's schema can be exported as JSON Schema:\n\n```json5\n// TodoItemComponent.to_json_schema\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"title\": {\n      \"type\": \"string\"\n    },\n    \"done\": {\n      \"type\": \"boolean\"\n    }\n  },\n  \"required\": [\"title\", \"done\"],\n  \"additional_properties\": false\n}\n```\n\nIts JSON Schema can be used to generate type definitions for other languages.\nIt helps consistent typing between different languages:\n\n```jsx\nimport type { TodoItemComponentProps } from './generated-types-from-json-schema/TodoItemComponent';\n\nexport const TodoItemComponent = ({ title, done }: TodoItemComponentProps) =\u003e {\n  return (\n    \u003cdiv\u003e\n      \u003cinput type=\"checkbox\" checked={done} /\u003e\n      \u003clabel\u003e{title}\u003c/label\u003e\n    \u003c/div\u003e\n  );\n};\n```\n\n## Getting Started\n### Installation\n\n1. Install the gem and add to the application's Gemfile by executing:\n\n```console\n$ bundle add json_schema_view\n```\n\n2. Run the generator:\n\n```console\n$ bin/rails generate json_schema_view:install\n    create  config/initializers/json_schema_view.rb\n    create  app/components/base_component.rb\n    create  app/components/base_props.rb\n    create  app/components/json_schema_definable.rb\n    create  app/components/component_schema_set.rb\n    create  app/components/example_todo_list_component.rb\n    create  app/components/example_todo_list_component/todo_item_resource.rb\n```\n\nThis task sets up `app/components` as the place of component definitions and an example component :-)\n\n\n### Export JSON Schema\n\nJsonSchemaView provides a rake task to export JSON Schema of components:\n\n```console\n$ rake json_schema_view:export[primary]\nExports resource classes in ComponentSchemaSet...\nExampleTodoListComponent -\u003e /path/to/rails/application/json_schema/ExampleTodoListComponent.json\n```\n\nThe behavior of the export task (output directory, classes to export, ...etc) can be configured on ComponentSchemaSet.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/increments/json_schema_view. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/increments/json_schema_view/blob/main/CODE_OF_CONDUCT.md).\n\n## Code of Conduct\n\nEveryone interacting in the JsonSchemaView project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/increments/json_schema_view/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincrements%2Fjson_schema_view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fincrements%2Fjson_schema_view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincrements%2Fjson_schema_view/lists"}