Class: ExampleTodoListComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/json_schema_view/rails/generators/install/templates/example/todo_list_component.rb,
lib/json_schema_view/rails/generators/install/templates/example/todo_item_resource.rb

Overview

This is an example definition of a component.

Examples:

You can use this component in a view like following code:

todo_items = [{ title: "Buy milk", done: false }, { title: "Buy eggs", done: true, note: "Large eggs are better" }]
render ExampleTodoListComponent.new(props: { todo_items: todo_items })

Extract the JSON Schema of this component:

ExampleTodoListComponent.props_class.to_json_schema
# => {
  "properties": {
    "type": "array",
    "items": {
      "type": "object",
      "properties": {
        "name": {
          "description": "The title of TODO item.",
          "type": "string"
        },
        "done": {
          "description": "Whether the TODO item is done or not.",
          "type": ["boolean"]
        },
        "note": {
          "description": "The additional description of TODO item.",
          "type": ["string"]
        }
      },
      "required": ["name", "done"],
      "additionalProperties": false
    }
  }
  "required": ["todo_items"],
  "additionalProperties": false
}

Defined Under Namespace

Classes: TodoItemResource