Fix Gitlab::GrapeOpenapi.generate
Gitlab::GrapeOpenapi.generate passes 2 arguments to Gitlab::GrapeOpenapi::Generator#initialize, but that constructor only accepts one. This results in:
ArgumentError: wrong number of arguments (given 2, expected 0..1)
Steps to reproduce
- Open
bundle exec rails console - Run:
spec = Gitlab::GrapeOpenapi.generate({ api_classes: [API::API] })
Current behavior
-
Gitlab::GrapeOpenapi.generate(api_classes, options = {})callsGenerator.new(api_classes, options).generate(2 arguments) -
Generator#initialize(options = {})only accepts 1 argument - This causes an
ArgumentError
Expected behavior
Gitlab::GrapeOpenapi.generate should work without raising an ArgumentError.
What needs to be done
Update Gitlab::GrapeOpenapi.generate to pass arguments correctly to Generator#initialize. The method should merge api_classes into the options hash before passing it to the constructor.
File: gems/gitlab-grape-openapi/lib/gitlab-grape-openapi.rb
Acceptance criteria
-
Gitlab::GrapeOpenapi.generate({ api_classes: [API::API] })executes without raisingArgumentError - Existing tests pass
- The generated OpenAPI spec is correct
Edited by Alberto Bignotti