Skip to content

Commit

Permalink
feat(api): use redoc only for documentation
Browse files Browse the repository at this point in the history
It looks nicer than Swagger, so let's focus on single tool only.
  • Loading branch information
nijel committed Oct 1, 2024
1 parent a9b7d54 commit dd82f40
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
3 changes: 1 addition & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ The API is accessible on the ``/api/`` URL and it is based on
You can use it directly or by :ref:`wlc`.

The API is also documented using OpenAPI 3.0 on the ``/api/schema/`` URL, you
can browse it using Swagger at ``/api/schema/swagger-ui/`` or Redoc at
``/api/schema/redoc/``.
can browse at ``/api/docs/``.

.. note::

Expand Down
3 changes: 3 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Not yet released.

Please follow :ref:`generic-upgrade-instructions` in order to perform update.

*
* There are several changes in :file:`settings_example.py`, most notable are the new settings for :ref:`api` in ``SPECTACULAR_SETTINGS`` and changes in ``REST_FRAMEWORK`` and ``INSTALLED_APPS``; please adjust your settings accordingly.

**Contributors**

.. include:: changes/contributors/5.8.rst
Expand Down
2 changes: 0 additions & 2 deletions weblate/settings_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,8 +828,6 @@
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
}
SPECTACULAR_SETTINGS = {
"SWAGGER_UI_DIST": "SIDECAR",
"SWAGGER_UI_FAVICON_HREF": "SIDECAR",
"REDOC_DIST": "SIDECAR",
"SERVE_URLCONF": "weblate.api.urls",
"TITLE": "Weblate's REST API",
Expand Down
17 changes: 2 additions & 15 deletions weblate/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
from django.views.decorators.cache import cache_control, cache_page
from django.views.decorators.vary import vary_on_cookie
from django.views.generic import RedirectView, TemplateView
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
SpectacularSwaggerView,
)
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView

import weblate.accounts.urls
import weblate.accounts.views
Expand Down Expand Up @@ -822,16 +818,7 @@
# OpenAPI schema
path("api/schema/", SpectacularAPIView.as_view(), name="schema"),
# API documentation
path(
"api/schema/swagger-ui/",
SpectacularSwaggerView.as_view(url_name="schema"),
name="swagger-ui",
),
path(
"api/schema/redoc/",
SpectacularRedocView.as_view(url_name="schema"),
name="redoc",
),
path("api/docs/", SpectacularRedocView.as_view(url_name="schema"), name="redoc"),
# Static pages
path("contact/", weblate.accounts.views.contact, name="contact"),
path("hosting/", weblate.accounts.views.hosting, name="hosting"),
Expand Down

0 comments on commit dd82f40

Please sign in to comment.