[14.0] base_rest_pydantic: New addon to use pydantic model into base_rest#221
Conversation
c9ff680 to
72d2e16
Compare
| return {"$ref": f"#/components/schemas/{schema_name}"} | ||
|
|
||
|
|
||
| class PydanticModelList(PydanticModel): |
There was a problem hiding this comment.
@sbidoul I wonder if I should delete this class. Lists could be supported by the base class by parsing the type given as a parameter and the specific list processing arguments only used in the case of a list.
from typing import List
...
@restapi.method(
[(["/", "/search"], "GET")],
input_param=PydanticModel(PartnerSearchParam),
output_param=PydanticModel(List[PartnerShortInfo]),
auth="public",
)
def search(self, partner_search_param):
"""
"""There was a problem hiding this comment.
Do we actually need PydanticModel at all in the input/output param declaration ? Could it be
input_param=PartnerSearchParam,
output_param=List[PartnerShortInfo],
and let the framework detect they derive from pydantic.BaseModel to do its magic ?
There was a problem hiding this comment.
iow, PydanticModel and PydanticModelList could be internal to the base_rest framework with restapi.method wrapping input_param and output_param in PydanticModel when it detects they derive from pydantic.BaseModel.
There was a problem hiding this comment.
I don't want to add more work on you. It can come as a future ergonomy improvement.
There was a problem hiding this comment.
I'll leave the code as is. It will be part of the next big evolution.
72d2e16 to
c509bd3
Compare
a633ddb to
c0a26bc
Compare
|
@andreampiovesana did you have the opportunity to test the module and the 'extendable-pydantic' lib? |
|
@andreampiovesana It seems I've to fix the demo addon |
| @@ -0,0 +1,26 @@ | |||
| # Translation of Odoo Server. | |||
There was a problem hiding this comment.
I don't know if this will break anything but this should be named base_rest_pydantic.pot
| } | ||
|
|
||
| def to_openapi_requestbody(self, service): | ||
| def to_openapi_requestbody(self, services, spec): |
There was a problem hiding this comment.
I have the feeling that services is an error here and should be singular service
30dbcf6 to
384feda
Compare
384feda to
8787eaa
Compare
|
/ocabot merge minor |
|
What a great day to merge this nice PR. Let's do it! |
|
Congratulations, your PR was merged at 2d0c216. Thanks a lot for contributing to OCA. ❤️ |
Uh oh!
There was an error while loading. Please reload this page.