Skip to content

Defining a request_body on a GET request should raise an error #146

Description

@connorshea

I'm pretty sure SoberSwag ignores request body params on GET requests (and that's presumably the expected behavior because the HTTP spec says to do that AFAICT). However, if you're not familiar with the behavior of the HTTP spec and create an endpoint like this:

define :get, :index, '/foo' do
  summary 'Foo'

  request_body(reporting: true) do
    attribute :bar, SoberSwag::Reporting::Input.text
  end

  response(:ok, 'the foos requested', Core::Types.reporting_list_serializer_of(FooOutput))
end
def index
  puts parsed_body.inspect # this prints an empty parsed body even when you pass `bar` as a request body param.
end

Then you'll just get an empty parsed_body object in the action, and that leads to very confusing problems while developing. SoberSwag should raise if the developer tries to define a request_body on a GET endpoint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions