Skip to content

Commit 6d72746

Browse files
authored
Merge pull request #822 from OpenConceptLab/issue-2272-swagger-expansions
OpenConceptLab/ocl_issues#2272 | Add swagger docs for collection expansions endpoints
2 parents a55a7f7 + 7f889cb commit 6d72746

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

core/collections/views.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from core.common.serializers import TaskSerializer
5353
from core.common.swagger_parameters import q_param, compress_header, page_param, verbose_param, \
5454
include_facets_header, sort_asc_param, sort_desc_param, updated_since_param, include_retired_param, limit_param, \
55-
canonical_url_param, all_versions_param
55+
canonical_url_param, all_versions_param, include_summary_param
5656
from core.common.tasks import add_references, export_collection, delete_collection, index_expansion_concepts, \
5757
index_expansion_mappings, seed_children_to_expansion
5858
from core.common.throttling import ThrottleUtil
@@ -834,6 +834,9 @@ def get_object(self, queryset=None):
834834
self.check_object_permissions(self.request, instance)
835835
return instance
836836

837+
@swagger_auto_schema(
838+
manual_parameters=[verbose_param, include_summary_param, page_param, limit_param]
839+
)
837840
def get(self, request, *args, **kwargs):
838841
return self.list(request, *args, **kwargs)
839842

@@ -853,6 +856,8 @@ def create(self, request, *args, **kwargs):
853856

854857

855858
class CollectionExpansionsView(CollectionBaseView, ListWithHeadersMixin):
859+
"""List all expansions across all versions of a collection."""
860+
856861
def get_serializer_class(self):
857862
if self.is_verbose():
858863
return ExpansionDetailSerializer
@@ -863,6 +868,9 @@ def get_queryset(self):
863868
self.check_object_permissions(self.request, instance)
864869
return Expansion.objects.filter(collection_version_id__in=instance.versions.values_list('id', flat=True))
865870

871+
@swagger_auto_schema(
872+
manual_parameters=[verbose_param, include_summary_param, page_param, limit_param]
873+
)
866874
def get(self, request, *args, **kwargs):
867875
return self.list(request, *args, **kwargs)
868876

core/common/swagger_parameters.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
LAST_LOGIN_BEFORE_PARAM, LAST_LOGIN_SINCE_PARAM, DATE_JOINED_SINCE_PARAM, DATE_JOINED_BEFORE_PARAM, \
77
CASCADE_HIERARCHY_PARAM, CASCADE_METHOD_PARAM, MAP_TYPES_PARAM, EXCLUDE_MAP_TYPES_PARAM, CASCADE_MAPPINGS_PARAM, \
88
INCLUDE_MAPPINGS_PARAM, CASCADE_LEVELS_PARAM, CASCADE_DIRECTION_PARAM, ALL, RETURN_MAP_TYPES, OMIT_IF_EXISTS_IN, \
9-
EQUIVALENCY_MAP_TYPES, CANONICAL_URL_REQUEST_PARAM
9+
EQUIVALENCY_MAP_TYPES, CANONICAL_URL_REQUEST_PARAM, INCLUDE_SUMMARY
1010
# HEADERS
1111
from core.orgs.constants import NO_MEMBERS
1212

@@ -187,6 +187,11 @@
187187
enum=['', 'hierarchy'],
188188
description='Hierarchy (nested) or Flat Response'
189189
)
190+
include_summary_param = openapi.Parameter(
191+
INCLUDE_SUMMARY, openapi.IN_QUERY, type=openapi.TYPE_BOOLEAN, default=False,
192+
description='Include summary counts of active concepts and mappings'
193+
)
194+
190195
task_state_param = openapi.Parameter(
191196
'state',
192197
openapi.IN_QUERY,

0 commit comments

Comments
 (0)