Class: SwaggerYard::Type
- Inherits:
-
Object
- Object
- SwaggerYard::Type
- Defined in:
- lib/swagger_yard/type.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(string) ⇒ Type
constructor
A new instance of Type.
- #model_name ⇒ Object
-
#ref? ⇒ Boolean
TODO: have this look at resource listing?.
- #to_h ⇒ Object
Constructor Details
#initialize(string) ⇒ Type
Returns a new instance of Type.
9 10 11 12 13 14 |
# File 'lib/swagger_yard/type.rb', line 9 def initialize(string) @source = string @schema = TypeParser.new.json_schema(string) @name = name_for(@schema) @name = name_for(@schema['items']) if @name == 'array' end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/swagger_yard/type.rb', line 7 def name @name end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
7 8 9 |
# File 'lib/swagger_yard/type.rb', line 7 def schema @schema end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/swagger_yard/type.rb', line 7 def source @source end |
Class Method Details
.from_type_list(types) ⇒ Object
3 4 5 |
# File 'lib/swagger_yard/type.rb', line 3 def self.from_type_list(types) new(types.first) end |
Instance Method Details
#model_name ⇒ Object
21 22 23 |
# File 'lib/swagger_yard/type.rb', line 21 def model_name ref? ? name : nil end |
#ref? ⇒ Boolean
TODO: have this look at resource listing?
17 18 19 |
# File 'lib/swagger_yard/type.rb', line 17 def ref? schema["$ref"] end |
#to_h ⇒ Object
25 26 27 |
# File 'lib/swagger_yard/type.rb', line 25 def to_h schema end |