rspec_api_documentation
rspec_api_documentation copied to clipboard
Encode body requests
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
<order><param1>1</param1><param2>2</param2></order>
Another example: