Class: GrapeSwagger::Entity::AttributeParser
- Inherits:
-
Object
- Object
- GrapeSwagger::Entity::AttributeParser
- Defined in:
- lib/grape-swagger/entity/attribute_parser.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
- #call(entity_options) ⇒ Object
-
#initialize(endpoint) ⇒ AttributeParser
constructor
A new instance of AttributeParser.
Constructor Details
#initialize(endpoint) ⇒ AttributeParser
Returns a new instance of AttributeParser.
6 7 8 |
# File 'lib/grape-swagger/entity/attribute_parser.rb', line 6 def initialize(endpoint) @endpoint = endpoint end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
4 5 6 |
# File 'lib/grape-swagger/entity/attribute_parser.rb', line 4 def endpoint @endpoint end |
Instance Method Details
#call(entity_options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/grape-swagger/entity/attribute_parser.rb', line 10 def call() documentation = [:documentation] entity_model = model_from() if entity_model name = endpoint.nil? ? entity_model.to_s.demodulize : endpoint.send(:expose_params_from_model, entity_model) return entity_model_type(name, ) else param = data_type_from() return param unless documentation param[:default] = documentation[:default] if documentation[:default] add_attribute_example(param, documentation[:example]) if (values = documentation[:values]) param[:enum] = values if values.is_a?(Array) end param = { type: :array, items: param } if documentation[:is_array] param end end |