Class: Swagger::Blocks::Nodes::PropertyNode

Inherits:
Node
  • Object
show all
Defined in:
lib/api_schema/patches/property_node.rb

Instance Method Summary collapse

Instance Method Details

#property_schema_for(serializer) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/api_schema/patches/property_node.rb', line 9

def property_schema_for(serializer)
  property serializer.name do
    key :type, serializer.type
    key :description, serializer.description
    requires serializer.required_fields
    serializer.fields.each do |f|
      property f.name do
        key :type, f.type
        key :format, f.format if f.format
        key :description, f.description
        key :enum, f.allowed_values unless f.allowed_values.empty?
      end
    end
    serializer.references.each do |r|
      property_schema_for(r)
    end
  end
end

#requires(fields) ⇒ Object



5
6
7
# File 'lib/api_schema/patches/property_node.rb', line 5

def requires(fields)
  key :required, fields
end