Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save r7kamura/f399fc45c58347b201d3 to your computer and use it in GitHub Desktop.
Save r7kamura/f399fc45c58347b201d3 to your computer and use it in GitHub Desktop.
$ gem i json_world
Fetching: json_world-0.2.2.gem (100%)
Successfully installed json_world-0.2.2
1 gem installed
$ pry -r json_world
[1] pry(main)> class A
[1] pry(main)* include JsonWorld::DSL
[1] pry(main)* property(:x, type: Array, items: { type: String })
[1] pry(main)* end
=> [#<JsonWorld::PropertyDefinition:0x007f9fffa9bb08
@options={:type=>Array, :items=>{:type=>String}, :parent=>A},
@property_name=:x>]
[2] pry(main)> puts A.to_json_schema
{
"properties": {
"x": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"x"
]
}
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment