|
4 | 4 | from django.conf import settings |
5 | 5 | from django.db.models import F |
6 | 6 | from django.http import Http404 |
| 7 | +from drf_yasg import openapi |
7 | 8 | from drf_yasg.utils import swagger_auto_schema |
8 | 9 | from pydash import get, compact |
9 | 10 | from rest_framework import status |
|
28 | 29 | compress_header, include_source_versions_param, include_collection_versions_param, cascade_method_param, |
29 | 30 | cascade_map_types_param, cascade_exclude_map_types_param, cascade_hierarchy_param, cascade_mappings_param, |
30 | 31 | cascade_levels_param, cascade_direction_param, cascade_view_hierarchy, return_map_types_param, |
31 | | - omit_if_exists_in_param, equivalency_map_types_param, search_from_latest_repo_header) |
| 32 | + omit_if_exists_in_param, equivalency_map_types_param, search_from_latest_repo_header, |
| 33 | + match_semantic_param, match_best_match_param, match_num_candidates_param, match_k_nearest_param, |
| 34 | + match_brief_param, match_encoder_model_param, match_reranker_param, match_offset_param) |
32 | 35 | from core.common.tasks import delete_concept, make_hierarchy |
33 | 36 | from core.common.throttling import ThrottleUtil |
34 | 37 | from core.common.utils import (to_parent_uri_from_kwargs, generate_temp_version, get_truthy_values, to_int, |
@@ -933,6 +936,49 @@ def get_repo_params(is_semantic, target_repo_params, target_repo_url): |
933 | 936 | raise Http400(f'Unable to resolve "target_repo_url": "{target_repo_url}"') |
934 | 937 | return repo_params |
935 | 938 |
|
| 939 | + @swagger_auto_schema( |
| 940 | + operation_description='Find matching concepts across repositories using structured input data.', |
| 941 | + operation_summary='$match - Find matching concepts', |
| 942 | + manual_parameters=[ |
| 943 | + verbose_param, include_retired_param, limit_param, page_param, match_offset_param, |
| 944 | + match_semantic_param, match_best_match_param, match_num_candidates_param, |
| 945 | + match_k_nearest_param, match_brief_param, match_encoder_model_param, match_reranker_param, |
| 946 | + ], |
| 947 | + request_body=openapi.Schema( |
| 948 | + type=openapi.TYPE_OBJECT, |
| 949 | + required=['rows'], |
| 950 | + properties={ |
| 951 | + 'target_repo_url': openapi.Schema( |
| 952 | + type=openapi.TYPE_STRING, |
| 953 | + description='Repository URL to match against. Either target_repo_url or target_repo is required.' |
| 954 | + ), |
| 955 | + 'target_repo': openapi.Schema( |
| 956 | + type=openapi.TYPE_OBJECT, |
| 957 | + description='Alternative to target_repo_url. Object with owner, source, source_version, ' |
| 958 | + 'owner_type fields.' |
| 959 | + ), |
| 960 | + 'rows': openapi.Schema( |
| 961 | + type=openapi.TYPE_ARRAY, |
| 962 | + items=openapi.Schema(type=openapi.TYPE_OBJECT), |
| 963 | + description='List of concept-like key-value pairs to match.' |
| 964 | + ), |
| 965 | + 'map_config': openapi.Schema( |
| 966 | + type=openapi.TYPE_ARRAY, |
| 967 | + items=openapi.Schema(type=openapi.TYPE_OBJECT), |
| 968 | + description='Optional list configuring mapping logic per row.' |
| 969 | + ), |
| 970 | + 'filter': openapi.Schema( |
| 971 | + type=openapi.TYPE_OBJECT, |
| 972 | + description='Filtering criteria including locale and faceted filters.' |
| 973 | + ), |
| 974 | + } |
| 975 | + ), |
| 976 | + responses={ |
| 977 | + 200: 'List of matched results per input row', |
| 978 | + 400: 'Missing required parameters (rows, target_repo_url/target_repo)', |
| 979 | + 403: 'User not approved for $match or on waitlist', |
| 980 | + } |
| 981 | + ) |
936 | 982 | def post(self, request, **kwargs): # pylint: disable=unused-argument |
937 | 983 | user = self.request.user |
938 | 984 | if user.is_mapper_waitlisted or not user.is_mapper_approved: |
|
0 commit comments