diff --git a/lib/workload/stateless/stacks/metadata-manager/app/pagination.py b/lib/workload/stateless/stacks/metadata-manager/app/pagination.py index b3c0f990e..ea477d725 100644 --- a/lib/workload/stateless/stacks/metadata-manager/app/pagination.py +++ b/lib/workload/stateless/stacks/metadata-manager/app/pagination.py @@ -6,7 +6,7 @@ class PaginationConstant(ABC): - ROWS_PER_PAGE = "rowsPerPage" + ROWS_PER_PAGE = "rows_per_page" PAGE = "page" COUNT = "count" diff --git a/lib/workload/stateless/stacks/metadata-manager/app/settings/base.py b/lib/workload/stateless/stacks/metadata-manager/app/settings/base.py index 39cf50b51..d4d39e474 100644 --- a/lib/workload/stateless/stacks/metadata-manager/app/settings/base.py +++ b/lib/workload/stateless/stacks/metadata-manager/app/settings/base.py @@ -44,6 +44,7 @@ "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", 'simple_history.middleware.HistoryRequestMiddleware', + "djangorestframework_camel_case.middleware.CamelCaseMiddleWare", ] ROOT_URLCONF = "app.urls.base" @@ -131,6 +132,20 @@ REST_FRAMEWORK = { "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination", "PAGE_SIZE": 10, + # https://www.django-rest-framework.org/api-guide/parsers/#camelcase-json + # https://github.com/vbabiy/djangorestframework-camel-case + "DEFAULT_RENDERER_CLASSES": ( + "djangorestframework_camel_case.render.CamelCaseJSONRenderer", + "djangorestframework_camel_case.render.CamelCaseBrowsableAPIRenderer", + ), + "DEFAULT_PARSER_CLASSES": ( + "djangorestframework_camel_case.parser.CamelCaseFormParser", + "djangorestframework_camel_case.parser.CamelCaseMultiPartParser", + "djangorestframework_camel_case.parser.CamelCaseJSONParser", + ), + "JSON_UNDERSCOREIZE": { + 'no_underscore_before_number': True, + }, } CORS_ORIGIN_ALLOW_ALL = True diff --git a/lib/workload/stateless/stacks/metadata-manager/deps/requirements-slim.txt b/lib/workload/stateless/stacks/metadata-manager/deps/requirements-slim.txt index 62e2cad70..5e4b2f00a 100644 --- a/lib/workload/stateless/stacks/metadata-manager/deps/requirements-slim.txt +++ b/lib/workload/stateless/stacks/metadata-manager/deps/requirements-slim.txt @@ -3,6 +3,7 @@ aws-xray-sdk # intentionally leave out version, the daily release of this dep is ok djangorestframework==3.15.2 +djangorestframework-camel-case==1.4.2 Django==5.1 django-cors-headers==4.4.0 django-environ==0.11.2 diff --git a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/pagination.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/pagination.py index b3c0f990e..ea477d725 100644 --- a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/pagination.py +++ b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/pagination.py @@ -6,7 +6,7 @@ class PaginationConstant(ABC): - ROWS_PER_PAGE = "rowsPerPage" + ROWS_PER_PAGE = "rows_per_page" PAGE = "page" COUNT = "count" diff --git a/lib/workload/stateless/stacks/workflow-manager/workflow_manager/pagination.py b/lib/workload/stateless/stacks/workflow-manager/workflow_manager/pagination.py index 409d2c01f..43802804f 100644 --- a/lib/workload/stateless/stacks/workflow-manager/workflow_manager/pagination.py +++ b/lib/workload/stateless/stacks/workflow-manager/workflow_manager/pagination.py @@ -6,7 +6,7 @@ class PaginationConstant(ABC): - ROWS_PER_PAGE = "rowsPerPage" + ROWS_PER_PAGE = "rows_per_page" PAGE = "page" COUNT = "count" diff --git a/skel/django-api/project_name/pagination.py b/skel/django-api/project_name/pagination.py index b3c0f990e..ea477d725 100644 --- a/skel/django-api/project_name/pagination.py +++ b/skel/django-api/project_name/pagination.py @@ -6,7 +6,7 @@ class PaginationConstant(ABC): - ROWS_PER_PAGE = "rowsPerPage" + ROWS_PER_PAGE = "rows_per_page" PAGE = "page" COUNT = "count"