Fix OpenAPI Schema yaml rendering for timedelta#9007
Conversation
| @classmethod | ||
| def represent_timedelta(cls, dumper, data): | ||
| value = str(data.total_seconds()) | ||
| return dumper.represent_scalar('tag:yaml.org,2002:str', value) |
There was a problem hiding this comment.
are you using represent_scalar from existing code?
There was a problem hiding this comment.
it is actually the function of yaml Dumper class for overriding the tag for different datatypes or python object.
so this function gives custom representation for timedelta and first argument is dumper obj where we are adding this function
| request = create_request('/') | ||
| schema = generator.get_schema(request=request) | ||
| ret = OpenAPIRenderer().render(schema) | ||
| assert b"openapi: " in ret |
There was a problem hiding this comment.
can you explain the asserts please? also it would be nice to see some additional tests if possible
There was a problem hiding this comment.
sure. this test renders openapi yaml definition from an example schema which has a duration field with a default value timedelta(0) and asserts is checking for "openapi" and the duration fields default value "0.0".
I think we can add checking the" !!python/object/apply:datetime.timedelta" tag is not in response.
please let me know if you have any suggestions for cases it would be a great.
There was a problem hiding this comment.
if you can extra tests it would be great
There was a problem hiding this comment.
I have added test case for rendering yaml with durationfield having minvalidator. Please check.
…#8950) Removed the `{{ field.choices|yesno:",disabled" }}` block because this triggers the loading of full database table worth of objects just to determine whether the multi-select widget should be set as disabled or not. Since this "disabled" marking feature is not present in the normal select field, then I propose to remove it also from the multi-select.
* Added Deprecation Warnings for CoreAPI * Bumped removal to DRF315 * Update rest_framework/__init__.py * Update rest_framework/filters.py * Update rest_framework/filters.py * Update tests/schemas/test_coreapi.py * Update rest_framework/filters.py * Update rest_framework/filters.py * Update tests/schemas/test_coreapi.py * Update tests/schemas/test_coreapi.py * Update tests/schemas/test_coreapi.py * Update tests/schemas/test_coreapi.py * Update rest_framework/pagination.py * Update rest_framework/pagination.py * Update rest_framework/pagination.py * Update rest_framework/pagination.py * Update rest_framework/schemas/coreapi.py * Update rest_framework/schemas/coreapi.py * Update rest_framework/schemas/coreapi.py * Update rest_framework/schemas/coreapi.py * Update rest_framework/schemas/coreapi.py * Update tests/schemas/test_coreapi.py * Update setup.cfg * Update tests/schemas/test_coreapi.py * Update tests/schemas/test_coreapi.py * Update tests/schemas/test_coreapi.py * Update tests/schemas/test_coreapi.py * Update tests/schemas/test_coreapi.py * Update tests/schemas/test_coreapi.py * Update rest_framework/pagination.py --------- Co-authored-by: Asif Saif Uddin <[email protected]>
…es (encode#7278) * Fix the case where if the namespace is not None and there's no match, NamespaceVersioning always raises NotFound even if DEFAULT_VERSION is set or None is in ALLOWED_VERSIONS * Add test cases
|
accepted on the ground of a bug fix to a pending deprecation feature. until people migrate and we have several more release before we remove it, people will face less bug. |
Uh oh!
There was an error while loading. Please reload this page.