Sha256: 31fc7157b4a7f722b390dbe0f5b3331c850047beaeda3f5e032cc70be9b14822
Contents?: true
Size: 601 Bytes
Versions: 2
Compression:
Stored size: 601 Bytes
Contents
module JSON module Generator class Dereferencer def self.dereference(schema) return schema unless schema.has_key?('properties') definitions = schema.delete('definitions') schema['properties'].each do |name, property| next unless property.has_key?('$ref') ref_name = property['$ref'].split('/').last raise NameError, "definition for #{ref_name} not found" unless definitions.has_key?(ref_name) property.merge!(definitions[ref_name]) property.delete('$ref') end schema end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
json-generator-0.0.1 | lib/json/generator/dereferencer.rb |
contracts_api_test-0.0.1 | lib/json/generator/dereferencer.rb |