user798719
user798719

Reputation: 9869

djangorestframework browsable api: how to show all available endpoints urls?

In djangorestframework, there is a browsable api. But how do I show a user an entire bird's eye view of all the possible API calls that he/she can make? I can only see one at a time right now and the user would have to already know the correct URL beforehand

i.e.,

http://localhost:8000/users
http://localhost:8000/books
http://localhost:8000/book/1/author

Thank you!

Upvotes: 13

Views: 10024

Answers (3)

dimyG
dimyG

Reputation: 817

Django-Rest-Swagger doesn't support OpenAPI 3.0 and is unlikely to support it soon, so if you want an actively maintained library that supports OpenAPI 3.0 then you should use drf-spectacular. It mostly works out of the box, and you can customize it a lot.

A side note: Your api client needs access to the internet so that it gets the swagger UI or ReDoc from CDNs. Alternatively you can serve those static files from your service with an optional additional package, the drf-spectacular-sidecar

Upvotes: 1

SohailAQ
SohailAQ

Reputation: 1040

Django-Rest-Swagger as mentioned in the accepted answer is no longer maintained.

This is a good alternative

https://github.com/axnsan12/drf-yasg

Upvotes: 3

user798719
user798719

Reputation: 9869

The answer is as Klahnen said. Use this:

https://django-rest-swagger.readthedocs.io/en/latest/

It works out of the box for me and it is exactly what I was hoping for. I still maintain, though, that the term browsable API implies that there is a table of contents available for consumers of your API to see. This app is a lifesaver and perhaps it should be included!

Upvotes: 6

Related Questions