Update lib/apipie/application.rb #77

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

Systho commented Jan 22, 2013

Use controller_path() when possible in order to deal with namespaced controller

@Systho Systho Update lib/apipie/application.rb
Use controller_path() when possible in order to deal with namespaced controller
4f3a196
Owner

iNecas commented Jan 23, 2013

There is a syntax error in this PR. Also, there are usecases where controller_name makes more sence (like versioning, see #75), I can imagine this being a contiguration option. Something like config.namespaced_resources or something like that…

Systho commented Jan 23, 2013

Sorry for the typo, I actually aliased controller_name to controller_path for my use case and I wrote this PR a bit quickly.

I do not understand why versioning might be a problem , can't we have routes like

class UsersController 
    api :GET, "/api/users/"
    api_version "1"
    def index
      # ...
    end 

class Namespaced::UsersController
    api :GET, "/api/namespaced/users/"
    api_version "1"
    def index
      # ...
    end 

being documented as

/apipie/1/users/index
/apipie/1/namespaced/users/index

?

Owner

iNecas commented Jan 23, 2013

I understand you use case, but there are others:

users can use modules for versions. Here is an example [1]. In this example, they use most of the v1 controllers for the v2 as well, and in v2 modules are only changed things (which makes tons of sence to prevent code copying). However, if we used controller_path in this example, the path would look like

/apipie/1/v1/users
/apipie/2/v1/users

and once the users resource was changed for v2, it would change to /apipie/2/v2/users, which is not what we want. We want see what the resource looks like in specified version, not caring what namespace it's defined in.

Therefore I'm in for making it an optional change. but chaning it for all users is not what we want.

[1] - https://github.com/theforeman/foreman/tree/develop/app/controllers/api

Systho commented Jan 23, 2013

That make perfect sense, thanks for your clear explanation :)

I'll try to come with a less intrusive approach for namespaced controllers

Systho closed this Jan 23, 2013

Owner

iNecas commented Jan 23, 2013

Thank you!

Systho deleted the Systho:patch-1 branch Jan 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment