Class: OpenapiFirst::BodyParser
- Inherits:
-
Object
- Object
- OpenapiFirst::BodyParser
- Defined in:
- lib/openapi_first/body_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.const_missing(const_name) ⇒ Object
7 8 9 10 11 |
# File 'lib/openapi_first/body_parser.rb', line 7 def self.const_missing(const_name) super unless const_name == :ParsingError warn 'DEPRECATION WARNING: OpenapiFirst::BodyParser::ParsingError is deprecated. Use OpenapiFirst::ParseError instead.' # rubocop:disable Layout/LineLength OpenapiFirst::ParseError end |
Instance Method Details
#parse(request, content_type) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/openapi_first/body_parser.rb', line 13 def parse(request, content_type) body = read_body(request) return if body.empty? return MultiJson.load(body) if content_type =~ (/json/i) && (content_type =~ /json/i) return request.POST if request.form_data? body rescue MultiJson::ParseError raise ParseError, 'Failed to parse body as JSON' end |