Skip to content

Commit

Permalink
openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Feb 29, 2024
1 parent d3102f9 commit da28de7
Show file tree
Hide file tree
Showing 4 changed files with 475 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/metrics/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import re_path
from django.urls import re_path, path

from . import views

Expand Down Expand Up @@ -40,4 +40,5 @@
views.UniqueUserVisitsQuery.as_view(),
name=views.UniqueUserVisitsQuery.view_name,
),
path('openapi.json', views.metrics_openapi_view, name='openapi'),
]
6 changes: 6 additions & 0 deletions api/metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
RegistriesModerationMetrics,
CountedAuthUsage,
)
from osf.metrics.openapi import get_metrics_openapi_json_dict
from osf.models import AbstractNode


Expand Down Expand Up @@ -633,3 +634,8 @@ def _build_query_payload(self, timespan):
payload = super()._build_query_payload(timespan)
payload['query']['bool']['filter'].insert(0, {'term': {'user_is_authenticated': True}})
return payload


def metrics_openapi_view(request):
_openapi_json = get_metrics_openapi_json_dict(reports=VIEWABLE_REPORTS)
return JsonResponse(_openapi_json, json_dumps_params={'indent': 2})
Loading

0 comments on commit da28de7

Please sign in to comment.