-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
[Bug] Not correct openapi json for ReDoc with dynamically generated classes #74
Comments
I guess I am not sure what the problem is. What would the expected outcome be? |
I'm trying just use template op.summary(f"Get obj {name}") with list of names. in https://github.com/sanic-org/sanic-ext/blob/main/sanic_ext/extensions/openapi/openapi.py line 412-422
There 'func' is key to collect data. But I have many dynamic view classes from same func-methods
Where viewItem_get is func. so ... |
I think I see what you are after here. I am not sure that we are likely to change this as it would potentially have a lot of complications for a narrow use case. Especially since I think there are a few alternatives that will get you there. Using
|
Thank you! It now work for me. I add functools.update_wrapper for copy doc from original, example: def gen_func(func, summary=None, description=None, operation=None):
f = partial(func)
if description is None:
update_wrapper(f, func)
description = f.__doc__
else:
f.__doc__ = description
return op.definition(summary=summary, description=description, operation=operation)(f)
.............
views.append(type(f"VIs_{name}",
(HTTPMethodView,),
{'model': model,
'_url': f'/{name}/',
'get': gen_func(viewItems_get,
summary=f'List of obj {name}',
description=f"List of objects {name}",
operation=f'get_{name}')})) Also next I add data of body and response. |
Hello. I make class views dynamically from SA models for REST api. And in ReDoc all summary for methods like last class.
Class view generate like this:
I find way to generate custom summary and all openapi fields for every my dynamic class-view.
I use Manjaro + firefox. Sanic v22.3.1 and sanic-ext==22.3.1
I try deepcopy, copy all objects and copy func-methods for set unique names for every gen but it not help all.
The text was updated successfully, but these errors were encountered: