2

I'm using the RSwag gem to create swagger OpenAPI specs: https://github.com/rswag/rswag

And I'm trying to get the schema for the response to appear in the Swagger API docs that are generated with the following spec:

path '/api/v2/ping' do
  get('returns a response when pinged') do
    tags 'Ping'
    consumes 'application/json'
    security [bearerAuth: []]
    parameter name: :Authorization, in: :header, type: :string
    description 'Ping the API'

    response(200, 'successful') do
      header 'X-Rate-Limit-Limit',
              schema: { type: :integer },
              description: 'The number of allowed requests in the current period'
      header 'X-Rate-Limit-Remaining',
              schema: { type: :integer },
              description: 'The number of remaining requests in the current period'
      schema type: :object,
              properties: {
                ok: { type: :boolean }
              }
      example 'application/json', :example, {
        ok: true
      }, 'Ping', 'A successful ping!'
      run_test!
    end

...

However the model doesn't appear next to the example:

enter image description here

When adding the schema to a response (not the request) it should be showing the model for the response object... e.g.

enter image description here

How do I add the schema to the response?

Cameron
  • 27,963
  • 100
  • 281
  • 483

1 Answers1

0

Try adding the line produces 'application/json' like it is in the examples in the documentation

I did not find any further explanation or reference in documentation but I had the same issue and solved it this way.

Martin
  • 1
  • 1