mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 17:47:08 +03:00
Fix Swagger schema API endpoint & add a test for it (#3592)
Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>
This commit is contained in:
parent
30c2d91020
commit
c22f2c7e9e
|
@ -329,7 +329,7 @@ def remove_drf_starter_files():
|
|||
)
|
||||
os.remove(
|
||||
os.path.join(
|
||||
"{{cookiecutter.project_slug}}", "users", "tests", "test_swagger_ui.py"
|
||||
"{{cookiecutter.project_slug}}", "users", "tests", "test_swagger.py"
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -333,6 +333,7 @@ REST_FRAMEWORK = {
|
|||
"rest_framework.authentication.TokenAuthentication",
|
||||
),
|
||||
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
|
||||
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
||||
}
|
||||
|
||||
# django-cors-headers - https://github.com/adamchainz/django-cors-headers#setup
|
||||
|
|
|
@ -14,3 +14,9 @@ def test_swagger_ui_not_accessible_by_normal_user(client):
|
|||
url = reverse("api-docs")
|
||||
response = client.get(url)
|
||||
assert response.status_code == 403
|
||||
|
||||
|
||||
def test_api_schema_generated_successfully(admin_client):
|
||||
url = reverse("api-schema")
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 200
|
Loading…
Reference in New Issue
Block a user