Class: SwaggerYard::Parameter
- Inherits:
-
Object
- Object
- SwaggerYard::Parameter
- Defined in:
- lib/swagger_yard/parameter.rb
Instance Attribute Summary collapse
-
#allow_multiple ⇒ Object
Returns the value of attribute allow_multiple.
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
-
#param_type ⇒ Object
Returns the value of attribute param_type.
-
#required ⇒ Object
Returns the value of attribute required.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
-
.from_path_param(name) ⇒ Object
TODO: support more variation in scope types.
- .from_yard_tag(tag) ⇒ Object
Instance Method Summary collapse
- #from_path? ⇒ Boolean
-
#initialize(name, type, description, options = {}) ⇒ Parameter
constructor
A new instance of Parameter.
Constructor Details
#initialize(name, type, description, options = {}) ⇒ Parameter
Returns a new instance of Parameter.
37 38 39 40 41 42 43 44 |
# File 'lib/swagger_yard/parameter.rb', line 37 def initialize(name, type, description, ={}) @name, @type, @description = name, type, description @required = [:required] || false @param_type = [:param_type] || 'query' @allow_multiple = [:allow_multiple] || false @from_path = [:from_path] || false end |
Instance Attribute Details
#allow_multiple ⇒ Object
Returns the value of attribute allow_multiple.
3 4 5 |
# File 'lib/swagger_yard/parameter.rb', line 3 def allow_multiple @allow_multiple end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/swagger_yard/parameter.rb', line 3 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/swagger_yard/parameter.rb', line 3 def name @name end |
#param_type ⇒ Object
Returns the value of attribute param_type.
3 4 5 |
# File 'lib/swagger_yard/parameter.rb', line 3 def param_type @param_type end |
#required ⇒ Object
Returns the value of attribute required.
3 4 5 |
# File 'lib/swagger_yard/parameter.rb', line 3 def required @required end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/swagger_yard/parameter.rb', line 3 def type @type end |
Class Method Details
.from_path_param(name) ⇒ Object
TODO: support more variation in scope types
28 29 30 31 32 33 34 35 |
# File 'lib/swagger_yard/parameter.rb', line 28 def self.from_path_param(name) new(name, Type.new("string"), "Scope response to #{name}", { required: true, allow_multiple: false, param_type: "path", from_path: true }) end |
.from_yard_tag(tag) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/swagger_yard/parameter.rb', line 5 def self.from_yard_tag(tag) tag = SwaggerYard.requires_name_and_type(tag) return nil unless tag name, = tag.name.split(/[\(\)]/) description = tag.text description = name if description.nil? || description.strip.empty? type = Type.from_type_list(tag.types) = {} unless .nil? .split(',').map(&:strip).tap do |arr| [:required] = !arr.delete('required').nil? [:allow_multiple] = !arr.delete('multiple').nil? [:param_type] = arr.last end end new(name, type, description, ) end |
Instance Method Details
#from_path? ⇒ Boolean
46 47 48 |
# File 'lib/swagger_yard/parameter.rb', line 46 def from_path? @from_path end |