@@ -17,19 +17,19 @@ Base Rest Datamodel
1717 :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1818 :alt: License: LGPL-3
1919.. |badge3 | image :: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github
20- :target: https://github.com/OCA/rest-framework/tree/16 .0/base_rest_pydantic
20+ :target: https://github.com/OCA/rest-framework/tree/18 .0/base_rest_pydantic
2121 :alt: OCA/rest-framework
2222.. |badge4 | image :: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23- :target: https://translation.odoo-community.org/projects/rest-framework-16 -0/rest-framework-16 -0-base_rest_pydantic
23+ :target: https://translation.odoo-community.org/projects/rest-framework-18 -0/rest-framework-18 -0-base_rest_pydantic
2424 :alt: Translate me on Weblate
2525.. |badge5 | image :: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26- :target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=16 .0
26+ :target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=18 .0
2727 :alt: Try me on Runboat
2828
2929|badge1 | |badge2 | |badge3 | |badge4 | |badge5 |
3030
31- This addon allows you to use Pydantic objects as params and/or response with your
32- REST API methods.
31+ This addon allows you to use Pydantic objects as params and/or response
32+ with your REST API methods.
3333
3434**Table of contents **
3535
@@ -39,65 +39,64 @@ REST API methods.
3939Usage
4040=====
4141
42- To use Pydantic instances as request and/or response of a REST service endpoint
43- you must:
42+ To use Pydantic instances as request and/or response of a REST service
43+ endpoint you must:
4444
45- * Define your Pydantic classes;
46- * Provides the information required to the ``odoo.addons.base_rest.restapi.method `` decorator;
45+ - Define your Pydantic classes;
46+ - Provides the information required to the
47+ ``odoo.addons.base_rest.restapi.method `` decorator;
4748
49+ .. code :: python
4850
49- .. code-block :: python
51+ from odoo.addons.base_rest import restapi
52+ from odoo.addons.component.core import Component
53+ from odoo.addons.pydantic.models import BaseModel
5054
55+ class PingMessage (BaseModel ):
56+ message: str
5157
52- from odoo.addons.base_rest import restapi
53- from odoo.addons.component.core import Component
54- from odoo.addons.pydantic.models import BaseModel
5558
56- class PingMessage (BaseModel ):
57- message: str
59+ class PingService (Component ):
60+ _inherit = ' base.rest.service'
61+ _name = ' ping.service'
62+ _usage = ' ping'
63+ _collection = ' my_module.services'
5864
5965
60- class PingService (Component ):
61- _inherit = ' base.rest.service'
62- _name = ' ping.service'
63- _usage = ' ping'
64- _collection = ' my_module.services'
65-
66-
67- @restapi.method (
68- [([" /pong" ], " GET" )],
69- input_param = restapi.PydanticModel(PingMessage),
70- output_param = restapi.PydanticModel(PingMessage),
71- auth = " public" ,
72- )
73- def pong (self , ping_message ):
74- return PingMessage(message = " Received: " + ping_message.message)
66+ @restapi.method (
67+ [([" /pong" ], " GET" )],
68+ input_param = restapi.PydanticModel(PingMessage),
69+ output_param = restapi.PydanticModel(PingMessage),
70+ auth = " public" ,
71+ )
72+ def pong (self , ping_message ):
73+ return PingMessage(message = " Received: " + ping_message.message)
7574
7675 Bug Tracker
7776===========
7877
7978Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues >`_.
8079In case of trouble, please check there if your issue has already been reported.
8180If you spotted it first, help us to smash it by providing a detailed and welcomed
82- `feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20base_rest_pydantic%0Aversion:%2016 .0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior** >`_.
81+ `feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20base_rest_pydantic%0Aversion:%2018 .0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior** >`_.
8382
8483Do not contact contributors directly about support or help with technical issues.
8584
8685Credits
8786=======
8887
8988Authors
90- ~~~~~~~
89+ -------
9190
9291* ACSONE SA/NV
9392
9493Contributors
95- ~~~~~~~~~~~~
94+ ------------
9695
97- * Laurent Mignon <laurent.mignon@acsone.eu>
96+ - Laurent Mignon <laurent.mignon@acsone.eu>
9897
9998Maintainers
100- ~~~~~~~~~~~
99+ -----------
101100
102101This module is maintained by the OCA.
103102
@@ -109,6 +108,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
109108mission is to support the collaborative development of Odoo features and
110109promote its widespread use.
111110
112- This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/16 .0/base_rest_pydantic >`_ project on GitHub.
111+ This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/18 .0/base_rest_pydantic >`_ project on GitHub.
113112
114113You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
0 commit comments