Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 3 tasks
MrKirat opened this issue Apr 19, 2024 · 0 comments
Open
1 of 3 tasks

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

MrKirat opened this issue Apr 19, 2024 · 0 comments

Comments

@MrKirat
Copy link

MrKirat commented Apr 19, 2024

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
@MrKirat MrKirat changed the title [BUG] <title> [BUG] Why rswag does not validate response schema types? Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant