Swaggerizing and running the specs are all fine. But when I go to the Swagger UI, click into the example and click Try it out, hitting execute does not use the body params that have been specified:

RSpec:
require 'swagger_helper'
describe 'Users API' do
path '/api/v1/users' do
post 'Creates a User' do
tags 'Users'
consumes 'application/json'
produces 'application/json'
parameter name: :user, in: :body, required: true, schema: {
type: :object,
properties: {
user: {
type: :object,
properties: {
email: { type: :string },
password: { type: :string }
},
required: ['email', 'password']
}
},
}
response '201', 'User created' do
let(:user) { { user: { email: '[email protected]', password: 'skylarplease' } } }
run_test!
end
end
end
end
I think this happens because the generated swagger_helper.rb file defaults to OpenAPI 3, and that version replaced the body parameter with requestBody (See: https://swagger.io/docs/specification/describing-request-body/) - At least it was what happened in my case.
I replaced
openapi: '3.0.1',
with:
swagger: '2.0',
in my swagger_helper.rb and got swagger ui to send the data with the request.
@idoqo It works for me too. thanks!
I think this happens because the generated swagger_helper.rb file defaults to OpenAPI 3
Yep this was a recent change in prep for me finishing off the OpenAPI 3 changes. Seems I was a bit hasty on that one.
@idoqo thanks you!!. you save me. I did spend time above a weeks for not generate curl and body parameters....
thank you @idoqo! Have been struggling with this for 1/2 a day now. rswag should update their generator so that the default swagger_helper.rb file does not default to openapi: '3.0.1' if they don't fully support it.
Most helpful comment
I think this happens because the generated
swagger_helper.rbfile defaults to OpenAPI 3, and that version replaced the body parameter with requestBody (See: https://swagger.io/docs/specification/describing-request-body/) - At least it was what happened in my case.I replaced
with:
in my
swagger_helper.rband got swagger ui to send the data with the request.