Class: Gitlab::GrapeOpenapi::Models::Response
- Inherits:
-
Object
- Object
- Gitlab::GrapeOpenapi::Models::Response
- Defined in:
- lib/gitlab/grape_openapi/models/response.rb
Overview
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#entity_class ⇒ Object
readonly
Returns the value of attribute entity_class.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(status_code:, description:, entity_class:, headers: {}, content_type: 'application/json', example: nil, examples: nil) ⇒ Response
constructor
A new instance of Response.
- #to_h(schema_registry) ⇒ Object
Constructor Details
#initialize(status_code:, description:, entity_class:, headers: {}, content_type: 'application/json', example: nil, examples: nil) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/gitlab/grape_openapi/models/response.rb', line 10 def initialize( status_code:, description:, entity_class:, headers: {}, content_type: 'application/json', example: nil, examples: nil) @status_code = status_code.to_s @description = description @entity_class = entity_class @headers = headers @content_type = content_type @example = example @examples = examples end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/response.rb', line 8 def content_type @content_type end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/response.rb', line 8 def description @description end |
#entity_class ⇒ Object (readonly)
Returns the value of attribute entity_class.
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/response.rb', line 8 def entity_class @entity_class end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/response.rb', line 8 def headers @headers end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
8 9 10 |
# File 'lib/gitlab/grape_openapi/models/response.rb', line 8 def status_code @status_code end |
Instance Method Details
#to_h(schema_registry) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/grape_openapi/models/response.rb', line 22 def to_h(schema_registry) response = { description: description, content: { content_type => { schema: { '$ref' => schema_ref(schema_registry) }, example: @example, examples: @examples }.compact } } response[:headers] = headers if headers.any? response end |