Class: Gitlab::GrapeOpenapi::Converters::RequestBodyConverter
- Inherits:
-
Object
- Object
- Gitlab::GrapeOpenapi::Converters::RequestBodyConverter
- Defined in:
- lib/gitlab/grape_openapi/converters/request_body_converter.rb
Constant Summary collapse
- DEFAULT_CONTENT_TYPE =
'application/json'- MULTIPART_FORM_DATA_CONTENT_TYPE =
'multipart/form-data'- GET_METHOD =
'GET'- DELETE_METHOD =
'DELETE'
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request_body_registry ⇒ Object
readonly
Returns the value of attribute request_body_registry.
-
#route ⇒ Object
readonly
Returns the value of attribute route.
Class Method Summary collapse
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(route:, options:, params:, request_body_registry:) ⇒ RequestBodyConverter
constructor
A new instance of RequestBodyConverter.
Constructor Details
#initialize(route:, options:, params:, request_body_registry:) ⇒ RequestBodyConverter
Returns a new instance of RequestBodyConverter.
18 19 20 21 22 23 |
# File 'lib/gitlab/grape_openapi/converters/request_body_converter.rb', line 18 def initialize(route:, options:, params:, request_body_registry:) @route = route @options = @params = params @request_body_registry = request_body_registry end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/gitlab/grape_openapi/converters/request_body_converter.rb', line 12 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
12 13 14 |
# File 'lib/gitlab/grape_openapi/converters/request_body_converter.rb', line 12 def params @params end |
#request_body_registry ⇒ Object (readonly)
Returns the value of attribute request_body_registry.
12 13 14 |
# File 'lib/gitlab/grape_openapi/converters/request_body_converter.rb', line 12 def request_body_registry @request_body_registry end |
#route ⇒ Object (readonly)
Returns the value of attribute route.
12 13 14 |
# File 'lib/gitlab/grape_openapi/converters/request_body_converter.rb', line 12 def route @route end |
Class Method Details
.convert(route:, options:, params:, request_body_registry:) ⇒ Object
14 15 16 |
# File 'lib/gitlab/grape_openapi/converters/request_body_converter.rb', line 14 def self.convert(route:, options:, params:, request_body_registry:) new(route: route, options: , params: params, request_body_registry: request_body_registry).convert end |
Instance Method Details
#convert ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/gitlab/grape_openapi/converters/request_body_converter.rb', line 25 def convert return nil if route_method == GET_METHOD || route_method == DELETE_METHOD return nil if params.empty? body_params = Models::RequestBody::Parameters.new(route: route, params: params).extract return nil if body_params.empty? build_request_body(body_params) end |