Sha256: 702e66a5c0d12943f38f54a2bf84c0e50fe541863a57185a18e0df3c38fa29fd
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
module Swagger::Serializer::RailsController private # render def render_as_schema(code, format, data) render format => render_serializer(code, format).serialize(data) end def render_serializer(code, format) response_obj = swagger_operation.responses[code] response_obj.content.send(format).serializer(Swagger::Serializer::Store.current.serialize_options) end def swagger_operation return @swagger_operation if @swagger_operation route = swagger_schema_route_from_request @swagger_operation = Swagger::Schema.current.path(route[:path]).send(route[:method]) end def swagger_schema_route_from_request return @swagger_schema_route_from_request if @swagger_schema_route_from_request Rails.application.routes.router.recognize(request) do |route| path = route.path.spec.to_s.sub("(.:format)", "").gsub(/:(\w+)/, "{\\1}") @swagger_schema_route_from_request = { path: path, method: request.request_method.underscore } return @swagger_schema_route_from_request end end # params def parameter_params @parameter_params ||= parameter_deserializer.data(params.permit!.to_h).deserialize.with_indifferent_access end def parameter_deserializer @parameter_deserializer ||= swagger_operation.parameters.deserializer(Swagger::Serializer::Store.current.deserialize_options) end def body_params @body_params ||= body_deserializer ? body_deserializer.deserialize(params.permit!.to_h).with_indifferent_access : {} end def body_deserializer @body_deserializer ||= if request.content_type swagger_operation.request_body.content[request.content_type]&.deserializer( Swagger::Serializer::Store.current.deserialize_options, ) end end def schema_params @schema_params ||= parameter_params.merge(body_params) end end
Version data entries
3 entries across 3 versions & 1 rubygems