Class: Meta::Metadata
- Inherits:
-
Object
- Object
- Meta::Metadata
- Includes:
- ExecutionMethods
- Defined in:
- lib/meta/application/metadata.rb
Defined Under Namespace
Modules: ExecutionMethods
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#request_body ⇒ Object
readonly
Returns the value of attribute request_body.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #generate_operation_doc(schemas, scope: []) ⇒ Object
-
#initialize(title: nil, description: nil, tags: [], parameters: {}, request_body: nil, responses: nil, scope: nil) ⇒ Metadata
constructor
A new instance of Metadata.
Methods included from ExecutionMethods
#parse_parameters, #parse_request_body, #render_entity, #set_response
Constructor Details
#initialize(title: nil, description: nil, tags: [], parameters: {}, request_body: nil, responses: nil, scope: nil) ⇒ Metadata
Returns a new instance of Metadata.
67 68 69 70 71 72 73 74 75 |
# File 'lib/meta/application/metadata.rb', line 67 def initialize(title: nil, description: nil, tags: [], parameters: {}, request_body: nil, responses: nil, scope: nil) @title = title @description = description @tags = @parameters = parameters.is_a?(Parameters) ? parameters : Parameters.new(parameters) @request_body = request_body @responses = responses.is_a?(Responses) ? responses : Responses.new(responses) @scope = scope end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
65 66 67 |
# File 'lib/meta/application/metadata.rb', line 65 def description @description end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
65 66 67 |
# File 'lib/meta/application/metadata.rb', line 65 def parameters @parameters end |
#request_body ⇒ Object (readonly)
Returns the value of attribute request_body.
65 66 67 |
# File 'lib/meta/application/metadata.rb', line 65 def request_body @request_body end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
65 66 67 |
# File 'lib/meta/application/metadata.rb', line 65 def responses @responses end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
65 66 67 |
# File 'lib/meta/application/metadata.rb', line 65 def scope @scope end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
65 66 67 |
# File 'lib/meta/application/metadata.rb', line 65 def @tags end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
65 66 67 |
# File 'lib/meta/application/metadata.rb', line 65 def title @title end |
Class Method Details
.new(meta = {}) ⇒ Object
109 110 111 |
# File 'lib/meta/application/metadata.rb', line 109 def new( = {}) .is_a?(Metadata) ? : super(**) end |
Instance Method Details
#[](key) ⇒ Object
77 78 79 |
# File 'lib/meta/application/metadata.rb', line 77 def [](key) send(key) end |
#generate_operation_doc(schemas, scope: []) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/meta/application/metadata.rb', line 81 def generate_operation_doc(schemas, scope: []) operation_object = {} operation_object[:summary] = title if title operation_object[:tags] = unless .empty? operation_object[:description] = description if description operation_object[:parameters] = parameters.to_swagger_doc if request_body schema = request_body.to_schema_doc(stage: :param, scope: self.scope + scope, schema_docs_mapping: schemas) if schema || true operation_object[:requestBody] = { content: { 'application/json' => { schema: schema } } } end end operation_object[:responses] = responses.to_swagger_doc(schemas, scope: self.scope + scope) operation_object.compact end |