FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • uis/devops/iam/activate-account/api
1 result
Show changes
Commits on Source (4)
# Changelog
## [1.2.1](https://gitlab.developers.cam.ac.uk/uis/devops/iam/activate-account/api/compare/1.2.0...1.2.1) (2025-02-27)
### Bug Fixes
* keep snake case in openapi schema token authentication ([417a7c8](https://gitlab.developers.cam.ac.uk/uis/devops/iam/activate-account/api/commit/417a7c84a69578cc8bf714c1111b00df8314bb9c))
## [1.2.0](https://gitlab.developers.cam.ac.uk/uis/devops/iam/activate-account/api/compare/1.1.0...1.2.0) (2025-02-25)
### Features
......
......@@ -224,11 +224,16 @@ SPECTACULAR_SETTINGS = {
],
"CAMELIZE_NAMES": True,
"POSTPROCESSING_HOOKS": [
"drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields",
"activate_account_project.spectacular.camelize_serializer_fields",
"drf_spectacular.hooks.postprocess_schema_enums",
],
}
SPECTACULAR_COMPONENTS_KEEP_SNAKE_CASE = [
"TokenRequest",
"TokenResponse",
]
# Allow all origins to access API.
CORS_URLS_REGEX = r"^.*$"
CORS_ORIGIN_ALLOW_ALL = True
......
from copy import deepcopy
from django.conf import settings
from drf_spectacular.contrib.djangorestframework_camel_case import (
camelize_serializer_fields as _camelize_serializer_fields,
)
def camelize_serializer_fields(result, generator, request, public):
"""
By default, camelize_serializer_fields will camelize all serializer fields. This function does
not know about any parser_classes and renderer_classes that are set on the view, so it will
camelize all serializer fields. This function is a wrapper around the original function that
will camelize all serializer fields, but will keep the schemas of the components in
SPECTACULAR_COMPONENTS_KEEP_SNAKE_CASE in snake case. This is necessary because the OpenAPI
schema definitions are used to generate the client SDKs, and the client SDKs expect the schema
definitions to be in snake case.
"""
snake_case_schemas = []
# Find all schemas that should keep their snake case
for (component_name, component_type), component in generator.registry._components.items():
if (
component_type == "schemas"
and component_name in settings.SPECTACULAR_COMPONENTS_KEEP_SNAKE_CASE
):
snake_case_schemas.append((component, deepcopy(component.schema)))
# Camelize all serializer fields
result = _camelize_serializer_fields(result, generator, request, public)
# Restore the schemas that should keep their snake case
for component, schema in snake_case_schemas:
component.schema = schema
return result
[tool.poetry]
name = "activate_account"
version = "1.2.0"
version = "1.2.1"
description = ""
authors = [ ]
readme = "README.md"
......