rswag/rswag

[BUG] Why rswag does not validate response schema types?

MrKirat opened this issue · 0 comments

Describe the bug

I expect that rswag validates response schema types. But that is not the case. I can enter anything as a type value and tests will pass. Here is a code snippet of the successful test:

        RSpec.describe 'api/v1/users', type: :request do
          let!(:user) { FactoryBot.create(:user) }
        
          path '/api/users' do
            get('list users') do
              tags 'Users'
              security [{ Token: [] }]
              consumes 'application/json'
              produces 'application/json'
        
              response(200, 'successful') do
                schema(
                  type: :array,
                  items: {
                    type: :object,
                    properties: {
                      name: { type: :unexisting_type }
                    },
                    required: %w[name]
                  }
                )
        
                run_test!
              end
            end
          end
        end

As you can see the type of name is :unexisting_type . I expected that rswag would raise some error, like undefined type :unexisting_type. Can I somehow achieve this behavior?

Additional context

I don't know if it matters, but on UI it shows the type is invalid:
Screenshot 2024-04-18 at 20 24 25

Dependency versions

  • Rswag: 2.13.0
  • RSpec: 3.12.0
  • Rails: 6.1.7.7
  • Ruby: 3.1.2

Relates to which version of OAS (OpenAPI Specification)

  • OAS2
  • OAS3
  • OAS3.1