Class: Apipie::Generator::Swagger::ResourceDescriptionComposite
- Inherits:
-
Object
- Object
- Apipie::Generator::Swagger::ResourceDescriptionComposite
- Defined in:
- lib/apipie/generator/swagger/resource_description_composite.rb
Instance Method Summary collapse
-
#initialize(resource_descriptions, language:) ⇒ ResourceDescriptionComposite
constructor
A new instance of ResourceDescriptionComposite.
- #paths ⇒ Hash
- #tags ⇒ Array
-
#to_swagger ⇒ Hash{Symbol->Array | Hash
].
Constructor Details
#initialize(resource_descriptions, language:) ⇒ ResourceDescriptionComposite
Returns a new instance of ResourceDescriptionComposite.
3 4 5 6 |
# File 'lib/apipie/generator/swagger/resource_description_composite.rb', line 3 def initialize(resource_descriptions, language:) @resource_descriptions = resource_descriptions @language = language end |
Instance Method Details
#paths ⇒ Hash
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/apipie/generator/swagger/resource_description_composite.rb', line 36 def paths results = {} @resource_descriptions.each do |resource_description| resource_description._methods.each_value do |method_description| next unless method_description.show result = Apipie::Generator::Swagger::MethodDescription::ApiSchemaService .new( Apipie::Generator::Swagger::MethodDescription::Decorator.new(method_description), language: @language ) .call results.deep_merge!(result) end end results end |
#tags ⇒ Array
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/apipie/generator/swagger/resource_description_composite.rb', line 17 def results = [] @resource_descriptions.each do |resource_description| next unless resource_description._full_description results << { name: resource_description._id, description: Apipie.app.translate( resource_description._full_description, @language ) } end results end |
#to_swagger ⇒ Hash{Symbol->Array | Hash
Returns ].
9 10 11 12 13 14 |
# File 'lib/apipie/generator/swagger/resource_description_composite.rb', line 9 def to_swagger { tags: , paths: paths } end |