-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Router ordering of paths is not respected #92
Comments
A hacky workaround would be a 'fix' extension which could force drf-spectacular to ignore the second view it encounters. |
Complicating things slightly is an extra Even if I rename one of the serializers, this problem still exists. The schema endpoints are not the same as the real endpoints. I have worked-around this by filtering |
very interesting. spectacular should process the routes as they come in. the endpoint sorting might be influencing it though. i believe this is an dict override (in spectacular) versus. "take the first matching route" in Django. i'll look into it. |
Not a huge priority for me, as I need my hacking of the urlconf to also get rid of |
@jayvdb please review the change and close. urlpattern overrides should now be properly handled in the schema. |
Yes this is working, but I cant use it, because I need to also disable the oscar-api Sorry I didnt reply earlier. It is a bit hard for me to easily verify anything as I have diverged so far. Project almost over. Will get to tidy/catch up later this week. |
np. you probably also have to wrap your |
Ya, or more likely forcibly filter oscar-api urls to remove the suffix |
@tfranzel , I just noticed that this code was duplicated from DRF core, which means the bug probably exists there. The code there hasnt changed. There isnt any open issue related to "get_api_endpoints". encode/django-rest-framework#6527 looks really relevant - but appears closed without a fix. @Lucidiot , do you know whether your problem was eventually solved in DRF core? |
My issue occurred while support for OpenAPI was barely starting in DRF 3.9; at that time, the default With Django 2.2 and DRF 3.9 I managed to recreate my issue: ns1 = [
path('foo', FooView.as_view(), name='foo')
]
ns2 = [
path('bar', BarView.as_view(), name='bar')
]
urlpatterns = [
path('ns1/', include((ns1, 'ns1'), namespace='ns1'))
path('ns2/', include((ns2, 'ns2'), namespace='ns2'))
] With CoreAPI, I would get the two But I just tried out something else instead: If I still have my two views with different patterns and different namespaces and different everything, but I use the same serializer in both views, then both views get the same |
This appears in the now familiar case of oscarapi and oscarapicheckout.
The order in
urls.py
must be (c.f. README of oscarapicheckout):However drf-spectacular processes the second one, including the identical path, and internally replaces the first view/serializer/etc with the unused second view/serializer/etc.
If I invert the order, the desired oscarapicheckout endpoint appears in the schema, but then it is not the one used by the url router.
The text was updated successfully, but these errors were encountered: