toastdriven/django-tastypie — Issue #392: overriden schema urls are not displayed in top level api view
Author: amenasse
Created: 2012-03-02 04:56:14+00:00
State: open

When overriding the api_get_schema view of a resource via `override_urls`, the top_level api view only shows the default schema url for the resource. I would expect it to show the overriden schema uri.

Example resource:

````python
from tastypie.api import Api
from tastypie.resources import ModelResource, Resource

class ExampleResource(Resource):

def override_urls(self):

return [

url(r"^OVERRIDE_SCHEMA/(?P%s)/$" % self._meta.resource_name,
self.wrap_view('get_schema'), name="api_get_schema"),
]

class Meta:
authorization = Authorization()

v1_api = Api(api_name="v1")
v1_api.register(ExampleResource())
````

GET http://127.0.0.1:8000/api/v1/?format=json

Actual Result:

```json
{

"example": {
"list_endpoint": "/api/v1/example/",
"schema": "/api/v1/schema/example/"
}

}
```

Expected Result:

```json
{

"example": {
"list_endpoint": "/api/v1/example/",
"schema": "/api/v1/OVERRIDE_SCHEMA/example/"
}

}
```
Since override_urls are prepended to base_urls we end up with two url patterns with the same name - `api_get_schema`.

````python

>>> reverse('api_get_schema',kwargs={'resource_name':'defaultbucket','api_name':"v1"})
'/api/v1/example/schema/'

`````

To work around this i am currently overriding the `base_urls` method instead of `override_urls`

I would be interested in doing a patch which would change the behaviour of override_urls to actually remove base url patterns with clashing names, but I guess this would break some backwards compatibility. I would be interested to get some feedback on this before attempting a doc or code patch.