class SwaggerYard::Model
Carries id (the class name) and properties for a referenced
complex model object as defined by swagger schema
Constants
- TAG_ORDER
Attributes
additional_properties[R]
description[R]
discriminator[R]
id[R]
inherits[R]
properties[R]
Public Class Methods
from_yard_object(yard_object)
click to toggle source
# File lib/swagger_yard/model.rb, line 11 def self.from_yard_object(yard_object) new.tap do |model| model.add_info(yard_object) model.parse_tags(yard_object.tags) yard_object.children.each do |child| next unless child.is_a?(YARD::CodeObjects::MethodObject) prop = Property.from_method(child) model.properties << prop if prop end end end
mangle(name)
click to toggle source
# File lib/swagger_yard/model.rb, line 23 def self.mangle(name) name.gsub(/[^[:alnum:]_]+/, '_') end
new()
click to toggle source
# File lib/swagger_yard/model.rb, line 27 def initialize @properties = [] @inherits = [] end
Public Instance Methods
add_info(yard_object)
click to toggle source
# File lib/swagger_yard/model.rb, line 36 def add_info(yard_object) @description = yard_object.docstring @id = Model.mangle(yard_object.path) end
property(key)
click to toggle source
# File lib/swagger_yard/model.rb, line 41 def property(key) properties.detect {|prop| prop.name == key } end
valid?()
click to toggle source
# File lib/swagger_yard/model.rb, line 32 def valid? !id.nil? && @has_model_tag end