rspec_api_documentation icon indicating copy to clipboard operation
rspec_api_documentation copied to clipboard

Encode body requests

Open sasharevzin opened this issue 6 years ago • 0 comments

Hi guys,

I had a request to write a spec that posts XML as a body. In this case, I have to use raw_post and spec will look like:

  post "/api" do
    let(:raw_post) { { param1: 1, param2: 2 }.to_xml(root: :order) }
    example_request 'Getting a list of orders' do
      expect(status).to eq(200)
    end
  end

after running rake docs:generate, generated XML request_body won't be encode in the output 😭 : https://github.com/zipmark/rspec_api_documentation/blob/57ece9131cb5272aeeae49e06ef7d8e572e84310/templates/rspec_api_documentation/html_example.mustache#L103

<order><param1>1</param1><param2>2</param2></order>

but expected to be encoded as response body: https://github.com/zipmark/rspec_api_documentation/blob/57ece9131cb5272aeeae49e06ef7d8e572e84310/templates/rspec_api_documentation/html_example.mustache#L121

&lt;order&gt;&lt;param1&gt;1&lt;/param1&gt;&lt;param2&gt;2&lt;/param2&gt;&lt;/order&gt;

Another example:

sasharevzin avatar Dec 11 '18 20:12 sasharevzin