-
Notifications
You must be signed in to change notification settings - Fork 771
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
add get_schema_operation_parameters() for Open API 3 generateschema #1086
add get_schema_operation_parameters() for Open API 3 generateschema #1086
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1086 +/- ##
=========================================
- Coverage 98.34% 98.1% -0.24%
=========================================
Files 15 15
Lines 1208 1216 +8
=========================================
+ Hits 1188 1193 +5
- Misses 20 23 +3
Continue to review full report at Codecov.
|
Hi @n2ygk. Super. Thanks for this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carltongibson If I change it to queryset = view.queryset
, the only test that fails is this one, because the get_queryset()
override is ignored:
django-filter/tests/rest_framework/test_backends.py
Lines 133 to 151 in 556ce27
def test_filterset_fields_list_with_bad_get_queryset(self): | |
""" | |
See: | |
* https://github.com/carltongibson/django-filter/issues/551 | |
""" | |
class BadGetQuerySetView(FilterFieldsRootView): | |
filterset_fields = ['decimal', 'date'] | |
def get_queryset(self): | |
raise AttributeError("I don't have that") | |
backend = DjangoFilterBackend() | |
with warnings.catch_warnings(record=True) as w: | |
warnings.simplefilter("always") | |
fields = backend.get_schema_fields(BadGetQuerySetView()) | |
self.assertEqual(fields, [], "get_schema_fields should handle AttributeError") | |
======================================================================
FAIL: test_filterset_fields_list_with_bad_get_queryset (tests.rest_framework.test_backends.GetSchemaFieldsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/alan/src/django-filter/tests/rest_framework/test_backends.py", line 150, in test_filterset_fields_list_with_bad_get_queryset
self.assertEqual(fields, [], "get_schema_fields should handle AttributeError")
AssertionError: Lists differ: [Field(name='decimal', required=False, loc[266 chars]one)] != []
First list contains 2 additional elements.
First extra element 0:
Field(name='decimal', required=False, location='query', schema=<coreschema.schemas.Number object at 0x10e10a9b0>, description=None, type=None, example=None)
“If I change...” Why would you do that? 🙂 It’s just not right to access the queryset directly. (That’s what I don’t follow...) |
No good reason? Because it's there? Because it's named |
I guess see tl;dr: Client code should always call |
Yep, learn something new every day. Sometimes for the second or third time. :-) |
@carltongibson just pinging to see if you are OK with merging this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super. Thanks.
Fixes #1083
Implements Open API 3 (formerly known as Swagger) schema generation by upstream DRF 3.9+
generateschema
management command.