Apipie/apipie-rails

Swagger generation mixes up controllers with same name:

davidwessman opened this issue · 4 comments

app/controllers/api/v1/pets_controller.rb

module Api
  module V1
    class PetsController < ApiController
      resource_description do
        tags(["Pets"])
      end
    end
  end
end

app/controllers/api/v1/owners/pets_controller.rb

module Api
  module V1
    module Owners
      class PetsController < ApiController
        resource_description do
          tags(["Owners"])
        end
      end
    end
  end
end

With these two controllers, the tags in swagger-output will be set to Owners for both PetsControllers.
(It could probably be set to Pets as well if it is something based on alphabetical sorting, but not the two separate tags)

Is there some matching done only on the class name? It needs to consider nested modules.

@PanosCodes Do you have any guidance here? Then I might try to fix it

I looked into it a bit, the missing tag never ends up in the Swagger generator.

It should be present in Apipie::MethodDescription::tag_list but I think it's not 🤔

Fixed it by adding the namespaced_resources: true, should this be the default in a future major version?

epugh commented

I ran into this issue and hunted around for a while till I found this ticket. Feels like since namespacing is common in Rails app, that this should default to true... ;-).

My first cut of adding some api! didn't go well because I have two BooksController, until I found this parameter.

image