Class: OpenStax::Api::RepresentableSchemaPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/openstax/api/representable_schema_printer.rb

Class Method Summary collapse

Class Method Details

.json(representer, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/openstax/api/representable_schema_printer.rb', line 5

def self.json(representer, options={})
  options[:include] ||= [:readable, :writeable]

  schema = json_schema(representer, options)

  json_string = JSON.pretty_generate(schema)

  "\n## Schema  {##{SecureRandom.hex(4)} .schema}\n" +
  "\n<pre class='code'>\n#{json_string}\n</pre>\n"
end