ruby-on-rails generator uses different names for controller class file and controller name in routes.rb.
I suppose it is related to the usage of tags.
3.1.2-SNAPSHOT via docker
openapi: 3.0.0
info:
version: 1.0.0
title: asdf
paths:
/foo_bar:
get:
summary: list all foobars
operationId: listFooBar
tags:
- foo_bar
responses:
'200':
description: OK
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/codegen_debug.yaml -g "ruby-on-rails" -o /local/out
generate ruby-on-rails stub with the yaml file above.
The command generates route
[...]
add_openapi_route 'GET', '//foo_bar', controller_name: 'fooBar', action_name: 'list_foo_bar'
[...]
but the generated controller file is named foo_bar_controller.rb
unknown
Use common name for controller in routes.rb and the actual controller class file
@and0x000 thanks for reporting the issue and suggesting a fix. May I know if you've time to contribute the fix? I can show you some good starting points.
@wing328 I can try. But beware, I am pretty new to both, rails as well as contributing on github.
https://github.com/OpenAPITools/openapi-generator/wiki/faq#how-can-i-submit-a-pr-to-fix-bugs-or-make-enhancements is a good starting point for contributing to this project
What does the correct route or controller file name look like in the example you provided above?
wrong:
add_openapi_route 'GET', '//foo_bar', controller_name: 'fooBar', action_name: 'list_foo_bar'
Message whent trying to start the server with it:
Exiting
/var/lib/gems/2.3.0/gems/actionpack-5.0.7/lib/action_dispatch/routing/mapper.rb:314:in `block (2 levels) in check_controller_and_action': 'fooBar' is not a supported controller name. This can lead to potential routing problems. See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use (ArgumentError)
correct:
add_openapi_route 'GET', '//foo_bar', controller_name: 'foo_bar', action_name: 'list_foo_bar'
@and0x000 thanks for the info, which is very useful in fixing the issue.
I've filed https://github.com/OpenAPITools/openapi-generator/pull/706 and my test result (tag: pet_foo_bar) looks good.
@and0x000 the PR has been merged into master. Please pull the latest master to give it a try to use the SNAPSHOT version.