rswag/rswag

[BUG] Root body not passed to curl when using openapi 3.0.1

arinhouck opened this issue · 0 comments

Describe the bug

Add root parameter object using openapi: '3.0.1' and it doesn't pass body to curl on swagger-ui.

Steps to Test or Reproduce

  1. Setup using
  config.swagger_docs = {
    'v1/swagger.json' => {
      openapi: '3.0.1',
  1. Add a test using root
require 'swagger_helper'

RSpec.describe 'oauth/tokens', type: :request do

  path '/oauth/token' do

    parameter name: :root, in: :body, schema: {
      type: :object,
      properties: {
        client_id: {
          type: :string,
          description: 'Client id'
        },
        grant_type: {
          type: :string,
          enum: %w[assertion],
          description: 'The grant types we support from oauth specification'
        },
        provider: {
          type: :string,
          enum: %w[linkedin],
          description: '3rd party oauth provider slug'
        },
        assertion: {
          type: :string,
          description: 'oauth code from the provider'
        }
      }
    }

    post('exchange code for token') do
      consumes 'application/json'

      response(200, 'successful') do
        let(:provider) { 'linkedin' }
        let(:client_id) { oauth_app.uid }
        let(:grant_type) { 'assertion' }
        let(:assertion) { 'some_code' }
        let!(:oauth_app) { create(:oauth_application, :linkedin) }
        let(:root) do
          {
            provider: provider,
            client_id: client_id,
            grant_type: grant_type,
            assertion: assertion
          }
        end

        after do |example|
          example.metadata[:response][:content] = {
            'application/json' => {
              example: JSON.parse(response.body, symbolize_names: true)
            }
          }
        end
        run_test!
      end
    end
  end

end
  1. Generate rswag and try to use swagger-ui
Screenshot 2023-07-03 at 4 51 35 PM

Expected behavior

I'd expect the curl to contain the json body like so:
Screenshot 2023-07-03 at 4 56 52 PM

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Dependency versions

The version of are you using for:

  • Rswag: 2.9.0
  • RSpec: 3.12.2 (rspec-core), rspec-rails (6.0.0)
  • Rails: 7.0.5
  • Ruby: 3.0.6

Relates to which version of OAS (OpenAPI Specification)

  • OAS2
  • OAS3
  • OAS3.1