Class: Meta::Responses
- Inherits:
-
Object
- Object
- Meta::Responses
- Extended by:
- Forwardable
- Defined in:
- lib/meta/application/responses.rb
Instance Attribute Summary collapse
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
Instance Method Summary collapse
-
#initialize(responses = {}) ⇒ Responses
constructor
A new instance of Responses.
- #to_swagger_doc(schemas, scope:) ⇒ Object
Constructor Details
#initialize(responses = {}) ⇒ Responses
Returns a new instance of Responses.
9 10 11 |
# File 'lib/meta/application/responses.rb', line 9 def initialize(responses = {}) @responses = responses || {} end |
Instance Attribute Details
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
7 8 9 |
# File 'lib/meta/application/responses.rb', line 7 def responses @responses end |
Instance Method Details
#to_swagger_doc(schemas, scope:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/meta/application/responses.rb', line 15 def to_swagger_doc(schemas, scope:) if responses.empty? { '200' => { description: '' } } else responses.transform_values do |schema| { description: '', # description 属性必须存在 content: schema ? { 'application/json' => { schema: schema.to_schema_doc(stage: :render, scope: scope, schema_docs_mapping: schemas) } } : nil }.compact end end end |