Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 500 Server Error with DRF browsable API and resolve blank Swagger API documentation #1603

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ click==8.1.2
coreapi==2.3.3
coreschema==0.0.4
cryptography==43.0.1
crispy-bootstrap4==2024.1
cwe2==3.0.0
dateparser==1.1.1
decorator==5.1.1
Expand All @@ -35,8 +36,8 @@ djangorestframework==3.15.2
doc8==0.11.1
docopt==0.6.2
docutils==0.17.1
drf-spectacular==0.27.2
drf-spectacular-sidecar==2024.7.1
drf-spectacular==0.24.2
drf-spectacular-sidecar==2022.10.1
executing==0.8.3
fetchcode==0.3.0
freezegun==1.2.1
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ install_requires =
django-filter>=24.0
django-widget-tweaks>=1.5.0
django-crispy-forms>=2.3
crispy-bootstrap4>=2024.1
django-environ>=0.11.0
gunicorn>=23.0.0

# for the API doc
drf-spectacular[sidecar]>=0.27.2
drf-spectacular[sidecar]>=0.24.2

#essentials
packageurl-python>=0.15
Expand Down
6 changes: 1 addition & 5 deletions vulnerabilities/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,10 @@ def filter_alias(self, queryset, name, value):
return self.queryset.filter(aliases__alias__icontains=alias)


class AliasViewSet(viewsets.ReadOnlyModelViewSet):
class AliasViewSet(VulnerabilityViewSet):
"""
Lookup for vulnerabilities by vulnerability aliases such as a CVE
(https://nvd.nist.gov/general/cve-process).
"""

queryset = Vulnerability.objects.all()
serializer_class = VulnerabilitySerializer
filter_backends = (filters.DjangoFilterBackend,)
filterset_class = AliasFilterSet
throttle_classes = [StaffUserRateThrottle, AnonRateThrottle]
2 changes: 2 additions & 0 deletions vulnerablecode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"rest_framework.authtoken",
"widget_tweaks",
"crispy_forms",
"crispy_bootstrap4",
# for API doc
"drf_spectacular",
# required for Django collectstatic discovery
Expand Down Expand Up @@ -196,6 +197,7 @@
str(PROJECT_DIR / "static"),
]

CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap4"

CRISPY_TEMPLATE_PACK = "bootstrap4"

Expand Down
Loading