Class: RequestHandler::BodyParser
- Inherits:
-
SchemaParser
- Object
- SchemaParser
- RequestHandler::BodyParser
- Defined in:
- lib/request_handler/body_parser.rb
Instance Method Summary collapse
-
#initialize(request:, schema:, schema_options: {}, included_schemas: {}) ⇒ BodyParser
constructor
A new instance of BodyParser.
- #run ⇒ Object
Constructor Details
#initialize(request:, schema:, schema_options: {}, included_schemas: {}) ⇒ BodyParser
Returns a new instance of BodyParser.
6 7 8 9 10 11 |
# File 'lib/request_handler/body_parser.rb', line 6 def initialize(request:, schema:, schema_options: {}, included_schemas: {}) raise MissingArgumentError, :"request.body" => 'is missing' if request.body.nil? super(schema: schema, schema_options: ) @request = request @included_schemas = included_schemas end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/request_handler/body_parser.rb', line 13 def run body, *included = flattened_request_body unless included_schemas? raise SchemaValidationError, included: 'must be empty' unless included.empty? return validate_schema(body) end validate_schemas(body, included) end |