lib/lurker/json/schema.rb in lurker-0.6.9 vs lib/lurker/json/schema.rb in lurker-0.6.10

- old
+ new

@@ -19,10 +19,20 @@ @parser = Lurker::Json::Parser.new(subschema_options) parse_schema(schema) end + def documentation_uri(extension = 'md') + @uri.to_s.sub(%r{^file:(//)?}, '').sub(/(\.json)?(\.yml)?(\.erb)?$/, ".#{extension}") + end + + def documentation + open(documentation_uri).read + rescue + @schema['description'] + end + def root? root_schema.blank? end def merge!(schema) @@ -38,12 +48,11 @@ replace!(property, property_schema) end end def replace!(property, property_schema) - @schema[property] = Lurker::Json::Parser.plain(subschema_options) - .parse_property(property, property_schema) + @schema[property] = @parser.plain.parse_property(property, property_schema) end def reorder! @schema = Hash[@schema.sort] self @@ -52,10 +61,10 @@ def to_hash(options = {}) hashify(@schema, options) end def to_json(options = {}) - hashify(@schema, options).to_json + to_hash(options).to_json end def to_yaml(options = {}) YAML.dump(to_hash(options)) end