Skip to content

Commit

Permalink
Merge branch 'drf-spectacular' into refactor-workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
irtazaakram committed Oct 2, 2024
2 parents 358daf8 + 23b8306 commit cbad568
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 50 deletions.
2 changes: 1 addition & 1 deletion notesapi/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Note(models.Model):
.. pii:: Stores 'text' and 'tags' about a particular course quote.
.. pii_types:: other
.. pii_retirement:: local_api, consumer_api
"""
"""
user_id = models.CharField(max_length=255, db_index=True, help_text="Anonymized user id, not course specific")
course_id = models.CharField(max_length=255, db_index=True)
usage_id = models.CharField(max_length=255, help_text="ID of XBlock where the text comes from")
Expand Down
2 changes: 1 addition & 1 deletion notesapi/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class AnnotationSearchView(ListAPIView):
* updated: DateTime. When was the last time annotation was updated.
"""

action = None
action = ''
params = {}
query_params = {}
search_with_usage_id = False
Expand Down
13 changes: 11 additions & 2 deletions notesserver/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# This value needs to be overriden in production.
SECRET_KEY = 'CHANGEME'
ALLOWED_HOSTS = ['localhost']
ALLOWED_HOSTS = ['*']

# ID and Secret used for authenticating JWT Auth Tokens
# should match those configured for `edx-notes` Client in EdX's /admin/oauth2/client/
Expand Down Expand Up @@ -57,12 +57,12 @@
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.staticfiles',
'drf_yasg',
'rest_framework',
'corsheaders',
'notesapi.v1',
# additional release utilities to ease automation
'release_util',
'drf_spectacular',
]
if not ES_DISABLED:
INSTALLED_APPS.extend(ES_APPS)
Expand All @@ -84,6 +84,15 @@
'DEFAULT_PERMISSION_CLASSES': ['notesapi.v1.permissions.HasAccessToken'],
'DEFAULT_PAGINATION_CLASS': 'notesapi.v1.paginators.NotesPaginator',
'DEFAULT_RENDERER_CLASSES': ('rest_framework.renderers.JSONRenderer',),
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
}

SPECTACULAR_SETTINGS = {
'TITLE': 'Edx Notes API',
'DESCRIPTION': 'Edx Notes API docs',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
'SCHEMA_PATH_PREFIX': '/api/'
}

# CORS is configured to allow all origins because requests to the
Expand Down
1 change: 1 addition & 0 deletions notesserver/settings/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import platform
import sys
from logging.handlers import SysLogHandler

from django.conf import settings


Expand Down
2 changes: 1 addition & 1 deletion notesserver/settings/yaml_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import yaml
from django.core.exceptions import ImproperlyConfigured
from path import path

from notesserver.settings.logger import build_logging_config
from path import path

from .common import * # pylint: disable=unused-wildcard-import, wildcard-import

Expand Down
18 changes: 4 additions & 14 deletions notesserver/urls.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
from django.urls import include, path, re_path
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from rest_framework import permissions
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView

import notesserver.views

schema_view = get_schema_view(
openapi.Info(
title="Edx Notes API",
default_version='v1',
description="Edx Notes API docs",
),
public=False,
permission_classes=[permissions.AllowAny],
)

urlpatterns = [
path('heartbeat/', notesserver.views.heartbeat, name='heartbeat'),
path('selftest/', notesserver.views.selftest, name='selftest'),
re_path(r'^robots.txt$', notesserver.views.robots, name='robots'),
path('', notesserver.views.root, name='root'),
path('api/', include('notesapi.urls', namespace='api')),
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
]
3 changes: 2 additions & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Django
requests
djangorestframework
drf-yasg
drf-spectacular
elasticsearch
elasticsearch-dsl
django-elasticsearch-dsl
Expand All @@ -19,3 +19,4 @@ newrelic
edx-django-release-util
edx-django-utils
edx-drf-extensions
pytz
39 changes: 26 additions & 13 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
# make upgrade
#
asgiref==3.8.1
# via django
attrs==24.2.0
# via
# django
# django-cors-headers
# jsonschema
# referencing
certifi==2024.8.30
# via
# elasticsearch
Expand All @@ -32,7 +34,7 @@ django==4.2.16
# django-waffle
# djangorestframework
# drf-jwt
# drf-yasg
# drf-spectacular
# edx-django-release-util
# edx-django-utils
# edx-drf-extensions
Expand All @@ -57,17 +59,17 @@ djangorestframework==3.15.2
# -r requirements/base.in
# django-elasticsearch-dsl-drf
# drf-jwt
# drf-yasg
# drf-spectacular
# edx-drf-extensions
dnspython==2.6.1
# via pymongo
drf-jwt==1.19.2
# via edx-drf-extensions
drf-yasg==1.21.7
drf-spectacular==0.27.2
# via -r requirements/base.in
edx-django-release-util==1.4.0
# via -r requirements/base.in
edx-django-utils==5.15.0
edx-django-utils==5.16.0
# via
# -r requirements/base.in
# edx-drf-extensions
Expand All @@ -91,7 +93,11 @@ gunicorn==23.0.0
idna==3.8
# via requests
inflection==0.5.1
# via drf-yasg
# via drf-spectacular
jsonschema==4.23.0
# via drf-spectacular
jsonschema-specifications==2023.12.1
# via jsonschema
mysqlclient==2.2.4
# via -r requirements/base.in
newrelic==10.0.0
Expand All @@ -101,7 +107,6 @@ newrelic==10.0.0
packaging==24.1
# via
# django-nine
# drf-yasg
# gunicorn
path==17.0.0
# via path-py
Expand All @@ -118,7 +123,7 @@ pyjwt[crypto]==2.9.0
# -r requirements/base.in
# drf-jwt
# edx-drf-extensions
pymongo==4.9.1
pymongo==4.10.1
# via edx-opaque-keys
pynacl==1.5.0
# via edx-django-utils
Expand All @@ -127,15 +132,23 @@ python-dateutil==2.9.0.post0
# -r requirements/base.in
# elasticsearch-dsl
pytz==2024.2
# via drf-yasg
# via -r requirements/base.in
pyyaml==6.0.2
# via
# drf-yasg
# drf-spectacular
# edx-django-release-util
requests==2.32.3
referencing==0.35.1
# via
# jsonschema
# jsonschema-specifications
requests==2.25.0
# via
# -r requirements/base.in
# edx-drf-extensions
rpds-py==0.20.0
# via
# jsonschema
# referencing
semantic-version==2.10.0
# via edx-drf-extensions
six==1.16.0
Expand All @@ -156,7 +169,7 @@ typing-extensions==4.12.2
# edx-opaque-keys
# elasticsearch-dsl
uritemplate==4.1.1
# via drf-yasg
# via drf-spectacular
urllib3==1.26.20
# via
# elasticsearch
Expand Down
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pluggy==1.5.0
# via tox
pyproject-api==1.8.0
# via tox
tox==4.20.0
tox==4.21.0
# via -r requirements/ci.in
virtualenv==20.26.6
# via tox
53 changes: 37 additions & 16 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ astroid==3.2.4
# via
# -r requirements/test.in
# pylint
cachetools==5.5.0
# via tox
attrs==24.2.0
# via
# -r requirements/base.txt
# jsonschema
# referencing
certifi==2024.8.30
# via
# -r requirements/base.txt
Expand Down Expand Up @@ -67,7 +70,7 @@ distlib==0.3.8
# django-waffle
# djangorestframework
# drf-jwt
# drf-yasg
# drf-spectacular
# edx-django-release-util
# edx-django-utils
# edx-drf-extensions
Expand Down Expand Up @@ -97,7 +100,7 @@ djangorestframework==3.15.2
# -r requirements/base.txt
# django-elasticsearch-dsl-drf
# drf-jwt
# drf-yasg
# drf-spectacular
# edx-drf-extensions
dnspython==2.6.1
# via
Expand All @@ -107,11 +110,11 @@ drf-jwt==1.19.2
# via
# -r requirements/base.txt
# edx-drf-extensions
drf-yasg==1.21.7
drf-spectacular==0.27.2
# via -r requirements/base.txt
edx-django-release-util==1.4.0
# via -r requirements/base.txt
edx-django-utils==5.15.0
edx-django-utils==5.16.0
# via
# -r requirements/base.txt
# edx-drf-extensions
Expand All @@ -134,7 +137,7 @@ elasticsearch-dsl==7.4.1
# django-elasticsearch-dsl-drf
factory-boy==3.3.1
# via -r requirements/test.in
faker==30.0.0
faker==30.1.0
# via factory-boy
filelock==3.16.1
# via
Expand All @@ -149,7 +152,7 @@ idna==3.8
inflection==0.5.1
# via
# -r requirements/base.txt
# drf-yasg
# drf-spectacular
iniconfig==2.0.0
# via pytest
isort==5.13.2
Expand All @@ -158,6 +161,16 @@ jinja2==3.1.4
# via
# code-annotations
# diff-cover
jsonschema==4.23.0
# via
# -r requirements/base.txt
# drf-spectacular
jsonschema-specifications==2023.12.1
# via
# -r requirements/base.txt
# jsonschema
lazy-object-proxy==1.10.0
# via astroid
markupsafe==2.1.5
# via jinja2
mccabe==0.7.0
Expand All @@ -174,7 +187,6 @@ packaging==24.1
# via
# -r requirements/base.txt
# django-nine
# drf-yasg
# gunicorn
# pyproject-api
# pytest
Expand Down Expand Up @@ -217,7 +229,7 @@ pylint==1.5.0
# via
# -c requirements/constraints.txt
# -r requirements/test.in
pymongo==4.9.1
pymongo==4.10.1
# via
# -r requirements/base.txt
# edx-opaque-keys
Expand All @@ -242,19 +254,27 @@ python-dateutil==2.9.0.post0
python-slugify==8.0.4
# via code-annotations
pytz==2024.2
# via
# -r requirements/base.txt
# drf-yasg
# via -r requirements/base.txt
pyyaml==6.0.2
# via
# -r requirements/base.txt
# code-annotations
# drf-yasg
# drf-spectacular
# edx-django-release-util
requests==2.32.3
referencing==0.35.1
# via
# -r requirements/base.txt
# jsonschema
# jsonschema-specifications
requests==2.25.0
# via
# -r requirements/base.txt
# edx-drf-extensions
rpds-py==0.20.0
# via
# -r requirements/base.txt
# jsonschema
# referencing
semantic-version==2.10.0
# via
# -r requirements/base.txt
Expand Down Expand Up @@ -287,10 +307,11 @@ typing-extensions==4.12.2
# via
# -r requirements/base.txt
# edx-opaque-keys
# faker
uritemplate==4.1.1
# via
# -r requirements/base.txt
# drf-yasg
# drf-spectacular
urllib3==1.26.20
# via
# -r requirements/base.txt
Expand Down

0 comments on commit cbad568

Please sign in to comment.