Class: SexyJSONSchemas::Properties::Ref

Inherits:
Base
  • Object
show all
Defined in:
lib/sexy_json_schemas/properties/ref.rb

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#type

Constructor Details

#initialize(name, schema, options = {}) ⇒ Ref

Returns a new instance of Ref.



4
5
6
7
# File 'lib/sexy_json_schemas/properties/ref.rb', line 4

def initialize(name, schema, options = {})
  super(name, options) 
  @schema = schema
end

Instance Method Details

#as_jsonObject



9
10
11
12
13
14
15
16
17
# File 'lib/sexy_json_schemas/properties/ref.rb', line 9

def as_json
  json = { "$ref" => @schema }

  if @options[:description]
    json['description'] = @options[:description]
  end

  json
end