Skip to content

Commit

Permalink
Merge pull request #50 from b2b-marketplace/feature/drf_spectacular
Browse files Browse the repository at this point in the history
Автогенерация документации drf-spectacular
  • Loading branch information
Ivan-Skvortsov authored Aug 12, 2023
2 parents 532be43 + 56fc270 commit 6dd596d
Show file tree
Hide file tree
Showing 6 changed files with 898 additions and 632 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,6 @@ cython_debug/
.idea/
media/
.DS_Store

# Vscode project settings
.vscode
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# backend

## Схема базы данных
Обновление картинки после изменения dbml с помощью команды:
```
npx --package=@softwaretechnik/dbml-renderer -- dbml-renderer -i docs/db.dbml -o docs/db.svg
```

Схему БД в интерактивном режиме можно посмотреть по ссылке:

[СХЕМА БД](https://dbdiagram.io/d/64bb081202bd1c4a5e7f8c0b)
# backend

## Схема базы данных
Обновление картинки после изменения dbml с помощью команды:
```
npx --package=@softwaretechnik/dbml-renderer -- dbml-renderer -i docs/db.dbml -o docs/db.svg
```

Схему БД в интерактивном режиме можно посмотреть по ссылке:

[СХЕМА БД](https://dbdiagram.io/d/64bb081202bd1c4a5e7f8c0b)


## Документация API
В проекте реализована автоматическая генерация документации. Документация доступна по адресам:
1) Swagger: `/api/v1/schema/swagger-ui/`
2) Redoc: `/api/v1/schema/redoc/`
13 changes: 13 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

THIRD_PARTY_APPS = [
"debug_toolbar",
"drf_spectacular",
"rest_framework",
]

Expand Down Expand Up @@ -131,3 +132,15 @@

if DEBUG:
INTERNAL_IPS = ["127.0.0.1"]

REST_FRAMEWORK = {
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
}

SPECTACULAR_SETTINGS = {
"TITLE": "b2b-marketplace",
"DESCRIPTION": (
"API веб-сервиса для взаимодействия между продавцами и покупателями оптовых товаров"
),
"VERSION": "0.0.1",
}
24 changes: 24 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
from django.contrib import admin
from django.urls import include, path
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
SpectacularSwaggerView,
)

from config.settings import DEBUG

api_schema_url_patterns = [
path(
route="",
view=SpectacularAPIView.as_view(),
name="schema",
),
path(
route="redoc/",
view=SpectacularRedocView.as_view(url_name="schema"),
name="redoc",
),
path(
route="swagger-ui/",
view=SpectacularSwaggerView.as_view(url_name="schema"),
name="swagger-ui",
),
]

urlpatterns = [
path(route="api/v1/schema/", view=include(api_schema_url_patterns)),
path("admin/", admin.site.urls),
]

Expand Down
Loading

0 comments on commit 6dd596d

Please sign in to comment.