Class: SwaggerYard::Type
- Inherits:
-
Object
- Object
- SwaggerYard::Type
- Defined in:
- lib/swagger_yard/type.rb
Constant Summary collapse
- MODEL_PATH =
Default model location path
'#/definitions/'.freeze
Instance Attribute Summary collapse
-
#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.
- #name ⇒ Object
- #schema ⇒ Object
- #schema_with(options = {}) ⇒ Object
Constructor Details
#initialize(string) ⇒ Type
Returns a new instance of Type.
12 13 14 15 |
# File 'lib/swagger_yard/type.rb', line 12 def initialize(string) @source = string @name = nil end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/swagger_yard/type.rb', line 10 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
#name ⇒ Object
17 18 19 20 21 22 |
# File 'lib/swagger_yard/type.rb', line 17 def name return @name if @name @name = name_for(schema) @name = name_for(schema['items']) if @name == 'array' @name end |
#schema ⇒ Object
24 25 26 |
# File 'lib/swagger_yard/type.rb', line 24 def schema @schema ||= TypeParser.new.json_schema(source) end |
#schema_with(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/swagger_yard/type.rb', line 28 def schema_with( = {}) model_path = && [:model_path] || MODEL_PATH if model_path != MODEL_PATH TypeParser.new(model_path).json_schema(source) else schema end end |