From 3893c58a878d7497877370a3cd273c2abb6a237a Mon Sep 17 00:00:00 2001 From: GonzaloUlla Date: Thu, 23 Aug 2018 01:59:06 -0300 Subject: [PATCH 1/5] Adding built-in Djang API docs --- helpo-api/Pipfile | 1 + helpo-api/Pipfile.lock | 42 +++++++++++++++++++++++++++++++++++++++++ helpo-api/helpo/urls.py | 4 +++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/helpo-api/Pipfile b/helpo-api/Pipfile index 9eeb89c0a..550d9ec59 100644 --- a/helpo-api/Pipfile +++ b/helpo-api/Pipfile @@ -36,6 +36,7 @@ opbeat = "*" whitenoise = "*" ipython = "*" requests = "*" +coreapi = "*" [requires] python_version = "3.6" diff --git a/helpo-api/Pipfile.lock b/helpo-api/Pipfile.lock index 84c338fb1..5ea1b4a50 100644 --- a/helpo-api/Pipfile.lock +++ b/helpo-api/Pipfile.lock @@ -137,6 +137,21 @@ ], "version": "==3.0.4" }, + "coreapi": { + "hashes": [ + "sha256:46145fcc1f7017c076a2ef684969b641d18a2991051fddec9458ad3f78ffc1cb", + "sha256:bf39d118d6d3e171f10df9ede5666f63ad80bba9a29a8ec17726a66cf52ee6f3" + ], + "index": "pypi", + "version": "==2.3.3" + }, + "coreschema": { + "hashes": [ + "sha256:5e6ef7bf38c1525d5e55a895934ab4273548629f16aed5c0a6caa74ebf45551f", + "sha256:9503506007d482ab0867ba14724b93c18a33b22b6d19fb419ef2d239dd4a1607" + ], + "version": "==0.0.4" + }, "cryptography": { "hashes": [ "sha256:21af753934f2f6d1a10fe8f4c0a64315af209ef6adeaee63ca349797d747d687", @@ -282,6 +297,12 @@ ], "version": "==0.2.0" }, + "itypes": { + "hashes": [ + "sha256:c6e77bb9fd68a4bfeb9d958fea421802282451a25bac4913ec94db82a899c073" + ], + "version": "==1.1.0" + }, "jdcal": { "hashes": [ "sha256:948fb8d079e63b4be7a69dd5f0cd618a0a57e80753de8248fd786a8a20658a07", @@ -296,6 +317,13 @@ ], "version": "==0.12.1" }, + "jinja2": { + "hashes": [ + "sha256:74c935a1b8bb9a3947c50a54766a969d4846290e1e788ea44c1392163723c3bd", + "sha256:f84be1bb0040caca4cea721fcbbbbd61f9be9464ca236387158b0feea01914a4" + ], + "version": "==2.10" + }, "kombu": { "hashes": [ "sha256:86adec6c60f63124e2082ea8481bbe4ebe04fde8ebed32c177c7f0cd2c1c9082", @@ -303,6 +331,12 @@ ], "version": "==4.2.1" }, + "markupsafe": { + "hashes": [ + "sha256:a6be69091dac236ea9c6bc7d012beab42010fa914c459791d627dad4910eb665" + ], + "version": "==1.0" + }, "odfpy": { "hashes": [ "sha256:6bcaf3b23aa9e49ed8c8c177266539b211add4e02402748a994451482a10cb1b", @@ -932,6 +966,14 @@ "markers": "python_version < '3.7' and implementation_name == 'cpython'", "version": "==1.1.0" }, + "uritemplate": { + "hashes": [ + "sha256:01c69f4fe8ed503b2951bef85d996a9d22434d2431584b5b107b2981ff416fbd", + "sha256:1b9c467a940ce9fb9f50df819e8ddd14696f89b9a8cc87ac77952ba416e0a8fd", + "sha256:c02643cebe23fc8adb5e6becffe201185bf06c40bda5c0b4028a93f1527d011d" + ], + "version": "==3.0.0" + }, "virtualenv": { "hashes": [ "sha256:2ce32cd126117ce2c539f0134eb89de91a8413a29baac49cbab3eb50e2026669", diff --git a/helpo-api/helpo/urls.py b/helpo-api/helpo/urls.py index 433fcec55..ce4c654f2 100644 --- a/helpo-api/helpo/urls.py +++ b/helpo-api/helpo/urls.py @@ -5,10 +5,12 @@ from rest_framework import routers from actividades import urls as actividades_urls from users import urls as users_urls +from rest_framework.documentation import include_docs_urls urlpatterns = [ url(r'^admin/', admin.site.urls), - url(r'auth/', include('knox.urls')) + url(r'auth/', include('knox.urls')), + url(r'^docs/', include_docs_urls(title='Helpo API')) ] urlpatterns += actividades_urls.urlpatterns From 01763b155193d934e23778d2a26b9601f944e951 Mon Sep 17 00:00:00 2001 From: GonzaloUlla Date: Thu, 23 Aug 2018 02:12:08 -0300 Subject: [PATCH 2/5] Using Swagger for API docs --- helpo-api/Pipfile | 2 +- helpo-api/Pipfile.lock | 31 +++++++++++++++++++++++++++++++ helpo-api/helpo/settings/base.py | 1 + helpo-api/helpo/urls.py | 6 ++++-- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/helpo-api/Pipfile b/helpo-api/Pipfile index 550d9ec59..ab28f8bc2 100644 --- a/helpo-api/Pipfile +++ b/helpo-api/Pipfile @@ -36,7 +36,7 @@ opbeat = "*" whitenoise = "*" ipython = "*" requests = "*" -coreapi = "*" +django-rest-swagger = "*" [requires] python_version = "3.6" diff --git a/helpo-api/Pipfile.lock b/helpo-api/Pipfile.lock index 5ea1b4a50..4b3164c42 100644 --- a/helpo-api/Pipfile.lock +++ b/helpo-api/Pipfile.lock @@ -253,6 +253,14 @@ "index": "pypi", "version": "==3.1.5" }, + "django-rest-swagger": { + "hashes": [ + "sha256:48f6aded9937e90ae7cbe9e6c932b9744b8af80cc4e010088b3278c700e0685b", + "sha256:b039b0288bab4665cd45dc5d16f94b13911bc4ad0ed55f74ad3b90aa31c87c17" + ], + "index": "pypi", + "version": "==2.2.0" + }, "djangorestframework": { "hashes": [ "sha256:b6714c3e4b0f8d524f193c91ecf5f5450092c2145439ac2769711f7eba89a9d9", @@ -369,6 +377,12 @@ ], "version": "==2.5.4" }, + "openapi-codec": { + "hashes": [ + "sha256:1bce63289edf53c601ea3683120641407ff6b708803b8954c8a876fe778d2145" + ], + "version": "==1.3.2" + }, "parso": { "hashes": [ "sha256:35704a43a3c113cce4de228ddb39aab374b8004f4f2407d070b6a2ca784ce8a2", @@ -513,6 +527,23 @@ ], "version": "==0.8.1" }, + "simplejson": { + "hashes": [ + "sha256:067a7177ddfa32e1483ba5169ebea1bc2ea27f224853211ca669325648ca5642", + "sha256:2fc546e6af49fb45b93bbe878dea4c48edc34083729c0abd09981fe55bdf7f91", + "sha256:354fa32b02885e6dae925f1b5bbf842c333c1e11ea5453ddd67309dc31fdb40a", + "sha256:37e685986cf6f8144607f90340cff72d36acf654f3653a6c47b84c5c38d00df7", + "sha256:3af610ee72efbe644e19d5eaad575c73fb83026192114e5f6719f4901097fce2", + "sha256:3b919fc9cf508f13b929a9b274c40786036b31ad28657819b3b9ba44ba651f50", + "sha256:3dd289368bbd064974d9a5961101f080e939cbe051e6689a193c99fb6e9ac89b", + "sha256:6c3258ffff58712818a233b9737fe4be943d306c40cf63d14ddc82ba563f483a", + "sha256:75e3f0b12c28945c08f54350d91e624f8dd580ab74fd4f1bbea54bc6b0165610", + "sha256:b1f329139ba647a9548aa05fb95d046b4a677643070dc2afc05fa2e975d09ca5", + "sha256:ee9625fc8ee164902dfbb0ff932b26df112da9f871c32f0f9c1bcf20c350fe2a", + "sha256:fb2530b53c28f0d4d84990e945c2ebb470edb469d63e389bf02ff409012fe7c5" + ], + "version": "==3.16.0" + }, "six": { "hashes": [ "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", diff --git a/helpo-api/helpo/settings/base.py b/helpo-api/helpo/settings/base.py index e94ee03e8..5c1efd6c2 100644 --- a/helpo-api/helpo/settings/base.py +++ b/helpo-api/helpo/settings/base.py @@ -39,6 +39,7 @@ def base_dir_join(*args): 'import_export', 'rest_framework', + 'rest_framework_swagger', 'knox', 'common', diff --git a/helpo-api/helpo/urls.py b/helpo-api/helpo/urls.py index ce4c654f2..771b8eba0 100644 --- a/helpo-api/helpo/urls.py +++ b/helpo-api/helpo/urls.py @@ -5,12 +5,14 @@ from rest_framework import routers from actividades import urls as actividades_urls from users import urls as users_urls -from rest_framework.documentation import include_docs_urls +from rest_framework_swagger.views import get_swagger_view + +schema_view = get_swagger_view(title='Pastebin API') urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'auth/', include('knox.urls')), - url(r'^docs/', include_docs_urls(title='Helpo API')) + url(r'^docs/', schema_view) ] urlpatterns += actividades_urls.urlpatterns From 5165b0a0736e240f681191d21cbbd15074b366f9 Mon Sep 17 00:00:00 2001 From: GonzaloUlla Date: Thu, 23 Aug 2018 02:35:20 -0300 Subject: [PATCH 3/5] Changing Swagger URL order and setting Helpo API name --- helpo-api/helpo/urls.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/helpo-api/helpo/urls.py b/helpo-api/helpo/urls.py index 771b8eba0..b0935378b 100644 --- a/helpo-api/helpo/urls.py +++ b/helpo-api/helpo/urls.py @@ -7,12 +7,11 @@ from users import urls as users_urls from rest_framework_swagger.views import get_swagger_view -schema_view = get_swagger_view(title='Pastebin API') +schema_view = get_swagger_view(title='Helpo API') urlpatterns = [ url(r'^admin/', admin.site.urls), - url(r'auth/', include('knox.urls')), - url(r'^docs/', schema_view) + url(r'auth/', include('knox.urls')) ] urlpatterns += actividades_urls.urlpatterns @@ -23,3 +22,5 @@ urlpatterns = [ url(r'^__debug__/', include(debug_toolbar.urls)), ] + urlpatterns + +urlpatterns += [ url(r'^docs/', schema_view) ] \ No newline at end of file From 5c1295b6f1f2770c814310d809efcfba33eaba9e Mon Sep 17 00:00:00 2001 From: GonzaloUlla Date: Fri, 24 Aug 2018 01:15:26 -0300 Subject: [PATCH 4/5] Adding log in URL config to Swagger --- helpo-api/helpo/settings/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/helpo-api/helpo/settings/base.py b/helpo-api/helpo/settings/base.py index 5c1efd6c2..99e6f82bb 100644 --- a/helpo-api/helpo/settings/base.py +++ b/helpo-api/helpo/settings/base.py @@ -124,3 +124,8 @@ def base_dir_join(*args): '10.0.2.2:8001', '10.0.2.2:8081' ) + +# Swagger +SWAGGER_SETTINGS = { + 'LOGIN_URL': '/auth/log_in/' +} \ No newline at end of file From eb0ed9a8f154ec7c10de4b2e3892c3d94eb12c8a Mon Sep 17 00:00:00 2001 From: GonzaloUlla Date: Fri, 24 Aug 2018 01:53:37 -0300 Subject: [PATCH 5/5] Big drowned hand --- helpo-api/Pipfile | 1 - 1 file changed, 1 deletion(-) diff --git a/helpo-api/Pipfile b/helpo-api/Pipfile index ab28f8bc2..9eeb89c0a 100644 --- a/helpo-api/Pipfile +++ b/helpo-api/Pipfile @@ -36,7 +36,6 @@ opbeat = "*" whitenoise = "*" ipython = "*" requests = "*" -django-rest-swagger = "*" [requires] python_version = "3.6"