Skip to content

Commit

Permalink
Merge pull request #414 from bento-platform/features/fetch-configurab…
Browse files Browse the repository at this point in the history
…le-extra-properties-schemas

Add endpoint for fetch extraPropertiesSchemaTypes
  • Loading branch information
noctillion committed Jun 29, 2023
2 parents 4860c75 + aed0ec1 commit ea58fd4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
12 changes: 12 additions & 0 deletions chord_metadata_service/restapi/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from chord_metadata_service.patients import models as patients_models
from chord_metadata_service.experiments import models as experiments_models
from chord_metadata_service.mcode.api_views import MCODEPACKET_PREFETCH, MCODEPACKET_SELECT
from chord_metadata_service.restapi.models import SchemaType
from drf_spectacular.utils import extend_schema, inline_serializer
from rest_framework import serializers

Expand Down Expand Up @@ -140,6 +141,17 @@ def overview(_request):
return Response(r)


@api_view(["GET"])
@permission_classes([OverrideOrSuperUserOnly])
def extra_properties_schema_types(_request):
"""
get:
Extra properties schema types
"""
schema_types = dict(SchemaType.choices)
return Response(schema_types)


@api_view(["GET", "POST"])
@permission_classes([OverrideOrSuperUserOnly])
def search_overview(request):
Expand Down
13 changes: 13 additions & 0 deletions chord_metadata_service/restapi/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ def test_service_info(self):
# TODO: Test compliance with spec


class ExtraPropertiesSchemaTypesTest(APITestCase):
def test_extra_properties_schema_types(self):
response = self.client.get('/api/extra_properties_schema_types')
response_obj = response.json()
expected_response = {
"PHENOPACKET": "Phenopacket",
"BIOSAMPLE": "Biosample",
"INDIVIDUAL": "Individual"
}
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response_obj, expected_response)


class OverviewTest(APITestCase):

def setUp(self) -> None:
Expand Down
6 changes: 5 additions & 1 deletion chord_metadata_service/restapi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
public_search_fields,
public_overview,
public_dataset,
search_overview
search_overview,
extra_properties_schema_types,
)
from chord_metadata_service.restapi.routers import BatchListRouter

Expand Down Expand Up @@ -89,6 +90,9 @@
path('mcode_schema', mcode_views.get_mcode_schema,
name="mcode-schema"),

# extra properties schema types
path('extra_properties_schema_types', extra_properties_schema_types, name="extra-properties-schema-types"),

# overviews (statistics)
path('overview', overview, name="overview"),
path('mcode_overview', mcode_overview, name="mcode-overview"),
Expand Down

0 comments on commit ea58fd4

Please sign in to comment.