-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Django Deployable Swagger (#797)
- Loading branch information
1 parent
efb00d8
commit 62809ba
Showing
18 changed files
with
216 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
"app", | ||
"aws_xray_sdk.ext.django", | ||
'simple_history', | ||
"drf_spectacular", | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|
@@ -146,6 +147,9 @@ | |
"JSON_UNDERSCOREIZE": { | ||
'no_underscore_before_number': True, | ||
}, | ||
"DEFAULT_AUTHENTICATION_CLASSES": [ | ||
"rest_framework.authentication.TokenAuthentication", | ||
], | ||
} | ||
|
||
CORS_ORIGIN_ALLOW_ALL = True | ||
|
@@ -164,3 +168,35 @@ | |
|
||
# turn off xray more generally and, you can overwrite with env var AWS_XRAY_SDK_ENABLED=true at runtime | ||
aws_xray_sdk.global_sdk_config.set_sdk_enabled(False) | ||
|
||
REST_FRAMEWORK['DEFAULT_SCHEMA_CLASS'] = 'drf_spectacular.openapi.AutoSchema' | ||
SPECTACULAR_SETTINGS = { | ||
'TITLE': 'Metadata Manager API', | ||
'DESCRIPTION': 'The Metadata Manager API for UMCCR.', | ||
'VERSION': '0.0.1', | ||
'SERVE_INCLUDE_SCHEMA': False, | ||
'SECURITY': [ | ||
{ | ||
"type": "http", | ||
"scheme": "bearer", | ||
"bearerFormat": "JWT", | ||
} | ||
], | ||
'CONTACT': { | ||
'name': 'UMCCR', | ||
'email': '[email protected]' | ||
}, | ||
"LICENSE": { | ||
"name": "MIT License", | ||
}, | ||
"EXTERNAL_DOCS": { | ||
"description": "Terms of service", | ||
"url": "https://umccr.org/", | ||
}, | ||
'CAMELIZE_NAMES': True, | ||
'POSTPROCESSING_HOOKS': [ | ||
'drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields', | ||
'drf_spectacular.hooks.postprocess_schema_enums' | ||
], | ||
'SCHEMA_PATH_PREFIX': f'/api/{API_VERSION}/', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,50 +24,12 @@ | |
|
||
INSTALLED_APPS += ( | ||
"django_extensions", | ||
"drf_spectacular", | ||
) | ||
|
||
ROOT_URLCONF = "app.urls.local" | ||
|
||
RUNSERVER_PLUS_PRINT_SQL_TRUNCATE = sys.maxsize | ||
|
||
REST_FRAMEWORK['DEFAULT_SCHEMA_CLASS'] = 'drf_spectacular.openapi.AutoSchema' | ||
|
||
SPECTACULAR_SETTINGS = { | ||
'TITLE': 'Metadata Manager API', | ||
'DESCRIPTION': 'The Metadata Manager API for UMCCR.', | ||
'VERSION': '0.0.1', | ||
'SERVE_INCLUDE_SCHEMA': False, | ||
'SECURITY': [ | ||
{ | ||
"type": "http", | ||
"scheme": "bearer", | ||
"bearerFormat": "JWT", | ||
} | ||
], | ||
'CONTACT': { | ||
'name': 'UMCCR', | ||
'email': '[email protected]' | ||
}, | ||
"LICENSE": { | ||
"name": "MIT License", | ||
}, | ||
"EXTERNAL_DOCS": { | ||
"description": "Terms of service", | ||
"url": "https://umccr.org/", | ||
}, | ||
'CAMELIZE_NAMES': True, | ||
'POSTPROCESSING_HOOKS': [ | ||
'drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields', | ||
'drf_spectacular.hooks.postprocess_schema_enums' | ||
], | ||
'SCHEMA_PATH_PREFIX': f'/api/{API_VERSION}/', | ||
} | ||
|
||
REDOC_SETTINGS = { | ||
"LAZY_RENDERING": False, | ||
} | ||
|
||
LOGGING = { | ||
'version': 1, | ||
'disable_existing_loggers': False, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
lib/workload/stateless/stacks/metadata-manager/app/urls/local.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
from django.urls import path | ||
from drf_spectacular.views import SpectacularJSONAPIView, SpectacularSwaggerView | ||
|
||
from .base import urlpatterns as base_urlpatterns | ||
|
||
urlpatterns = base_urlpatterns + [ | ||
path('schema/openapi.json', SpectacularJSONAPIView.as_view(), name='schema'), | ||
path('swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), | ||
name='swagger-ui'), | ||
# Some URL that only exists in the local environment | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
"rest_framework", | ||
"sequence_run_manager", | ||
"aws_xray_sdk.ext.django", | ||
"drf_spectacular", | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|
@@ -143,6 +144,9 @@ | |
"JSON_UNDERSCOREIZE": { | ||
'no_underscore_before_number': True, | ||
}, | ||
"DEFAULT_AUTHENTICATION_CLASSES": [ | ||
"rest_framework.authentication.TokenAuthentication", | ||
], | ||
} | ||
|
||
CORS_ORIGIN_ALLOW_ALL = True | ||
|
@@ -161,3 +165,37 @@ | |
|
||
# turn off xray more generally and, you can overwrite with env var AWS_XRAY_SDK_ENABLED=true at runtime | ||
aws_xray_sdk.global_sdk_config.set_sdk_enabled(False) | ||
|
||
# --- drf-spectacular settings | ||
|
||
REST_FRAMEWORK['DEFAULT_SCHEMA_CLASS'] = 'drf_spectacular.openapi.AutoSchema' | ||
|
||
SPECTACULAR_SETTINGS = { | ||
'TITLE': 'UMCCR OrcaBus sequence_run_manager API', | ||
'DESCRIPTION': 'UMCCR OrcaBus sequence_run_manager API', | ||
'VERSION': API_VERSION, | ||
'SERVE_INCLUDE_SCHEMA': False, | ||
'SECURITY': [ | ||
{ | ||
"type": "http", | ||
"scheme": "bearer", | ||
"bearerFormat": "JWT", | ||
} | ||
], | ||
'CONTACT': { | ||
'name': 'UMCCR', | ||
'email': '[email protected]' | ||
}, | ||
"LICENSE": { | ||
"name": "MIT License", | ||
}, | ||
"EXTERNAL_DOCS": { | ||
"description": "Terms of service", | ||
"url": "https://umccr.org/", | ||
}, | ||
'CAMELIZE_NAMES': True, | ||
'POSTPROCESSING_HOOKS': [ | ||
'drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields', | ||
'drf_spectacular.hooks.postprocess_schema_enums' | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,43 +23,9 @@ | |
|
||
INSTALLED_APPS += ( | ||
"django_extensions", | ||
"drf_spectacular", | ||
) | ||
|
||
ROOT_URLCONF = "sequence_run_manager.urls.local" | ||
|
||
RUNSERVER_PLUS_PRINT_SQL_TRUNCATE = sys.maxsize | ||
|
||
# --- drf-spectacular settings | ||
|
||
REST_FRAMEWORK['DEFAULT_SCHEMA_CLASS'] = 'drf_spectacular.openapi.AutoSchema' | ||
|
||
SPECTACULAR_SETTINGS = { | ||
'TITLE': 'UMCCR OrcaBus sequence_run_manager API', | ||
'DESCRIPTION': 'UMCCR OrcaBus sequence_run_manager API', | ||
'VERSION': API_VERSION, | ||
'SERVE_INCLUDE_SCHEMA': False, | ||
'SECURITY': [ | ||
{ | ||
"type": "http", | ||
"scheme": "bearer", | ||
"bearerFormat": "JWT", | ||
} | ||
], | ||
'CONTACT': { | ||
'name': 'UMCCR', | ||
'email': '[email protected]' | ||
}, | ||
"LICENSE": { | ||
"name": "MIT License", | ||
}, | ||
"EXTERNAL_DOCS": { | ||
"description": "Terms of service", | ||
"url": "https://umccr.org/", | ||
}, | ||
'CAMELIZE_NAMES': True, | ||
'POSTPROCESSING_HOOKS': [ | ||
'drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields', | ||
'drf_spectacular.hooks.postprocess_schema_enums' | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/local.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
from django.urls import path | ||
from drf_spectacular.views import SpectacularJSONAPIView, SpectacularSwaggerView | ||
|
||
from .base import urlpatterns as base_urlpatterns | ||
|
||
urlpatterns = base_urlpatterns + [ | ||
path('schema/openapi.json', SpectacularJSONAPIView.as_view(), name='schema'), | ||
path('swagger-ui/', | ||
SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'), | ||
# Some URL that only exists in the local environment | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.