whitedogg13 / django-rest-framework-redocs Goto Github PK
View Code? Open in Web Editor NEWAutomatically enable live API page for DRF, support both Django 1.x and 2.x
License: MIT License
Automatically enable live API page for DRF, support both Django 1.x and 2.x
License: MIT License
Send requests with:
Authorization : Bearer
instead of
Authorization : Token
As our django-rest-framework backend use Bearer token for authentication, which lead us to have unauthorize with ervery request send from redocs as it use Token
This is django-oscar-api-checkout
, but the problem is more general. It probably isnt possibly to forge a request
, so the calling code should be guarded in try/except to allow for serializers which can not be instantiated without context.
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python3.8/site-packages/redocs/views.py", line 29, in get_endpoints
api_parser.parse()
File "/usr/lib/python3.8/site-packages/redocs/api_parser.py", line 28, in parse
self._parse(
File "/usr/lib/python3.8/site-packages/redocs/api_parser.py", line 41, in _parse
self._parse(
File "/usr/lib/python3.8/site-packages/redocs/api_parser.py", line 48, in _parse
api_endpoint = ApiEndpoint(pattern, prefix)
File "/usr/lib/python3.8/site-packages/redocs/api_endpoint.py", line 28, in __init__
self.output_fields = self._get_serializer_fields(self.view.cls.serializer_class())
File "/usr/lib/python3.8/site-packages/oscarapicheckout/serializers.py", line 106, in __init__
assert request is not None, (
AssertionError: `PaymentMethodsSerializer` requires the request in the serializer context. Add `context={'request': request}` when instantiating the serializer.
I'll bet this is due to django-attachments ...
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python3.8/site-packages/redocs/views.py", line 29, in get_endpoints
api_parser.parse()
File "/usr/lib/python3.8/site-packages/redocs/api_parser.py", line 28, in parse
self._parse(
File "/usr/lib/python3.8/site-packages/redocs/api_parser.py", line 41, in _parse
self._parse(
File "/usr/lib/python3.8/site-packages/redocs/api_parser.py", line 48, in _parse
api_endpoint = ApiEndpoint(pattern, prefix)
File "/usr/lib/python3.8/site-packages/redocs/api_endpoint.py", line 26, in __init__
self.input_fields = self._get_serializer_fields(self.view.cls.serializer_class())
File "/usr/lib/python3.8/site-packages/redocs/api_endpoint.py", line 104, in _get_serializer_fields
getattr(serializer.Meta.model, key).field.related_model.__name__)
AttributeError: 'NoneType' object has no attribute '__name__'
Please find below my stack trace.
File "/Users/dhruv/Documents/community/unchained/venv3/lib/python3.6/site-packages/redocs/views.py", line 27, in get_endpoints
api_parser.parse()
File "/Users/dhruv/Documents/community/unchained/venv3/lib/python3.6/site-packages/redocs/api_parser.py", line 28, in parse
self._parse(self.patterns, self.endpoints)
File "/Users/dhruv/Documents/community/unchained/venv3/lib/python3.6/site-packages/redocs/api_parser.py", line 45, in _parse
api_endpoint = ApiEndpoint(pattern, prefix)
File "/Users/dhruv/Documents/community/unchained/venv3/lib/python3.6/site-packages/redocs/api_endpoint.py", line 11, in __init__
self.complete_path = self._get_complete_path(pattern, prefix)
File "/Users/dhruv/Documents/community/unchained/venv3/lib/python3.6/site-packages/redocs/api_endpoint.py", line 53, in _get_complete_path
regex = pattern._regex if hasattr(pattern, "_regex") else pattern.pattern._regex
AttributeError: 'RoutePattern' object has no attribute '_regex'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.