You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fix needs a pull request to drf-yasg which makes drf-yasg to use JSONRenderer specified in django settings instead of direct json.dumps and drf.JSONRenderer calls.
Hey, guys. Met same bug recently and decided to prepare it's description for you to assist with making problem visibility more clear.
Bug description
When the argument of a route is annotated as enum and default value is set, following exception happens on attempt to access Swagger schema: TypeError: Object of type 'SomeEnum' is not JSON serializable
To Reproduce
Prepare a controller with some route_get;
Add a parameter to route_get like: @route_get('/hello/{?param}');
Annotate parameter with enum and set enum-based default;
from enum import Enum
import winter
class FooParam(Enum)
FOO = 'foo'
BAR = 'bar'
@winter.controller
class HelloWorldController:
@winter.route_get('/hello/{?param}')
def hello(self, param: FooParam1 = FooParam.FOO):
return f'Hello, world!'
Properly setup drf-yasg to a project:
4.1. Set 'DEFAULT_AUTO_SCHEMA_CLASS': 'winter_openapi.inspectors.SwaggerAutoSchema' in SWAGGER_SETTINGS;
4.2. Call winter_openapi.setup() somewhere in service entrypoint code;
Try access Swagger schema.
Expected behavior
Default enum value is scanned normally, Swagger schema is successfully built and can be accessed.
Code snippets
Minimal code snippet is given above.
Using drf-yasg 1.13 doesn't seem to help
The text was updated successfully, but these errors were encountered: