@@ -17,19 +17,19 @@ Base Rest Datamodel
17
17
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18
18
:alt: License: LGPL-3
19
19
.. |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
21
21
:alt: OCA/rest-framework
22
22
.. |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
24
24
:alt: Translate me on Weblate
25
25
.. |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
27
27
:alt: Try me on Runboat
28
28
29
29
|badge1 | |badge2 | |badge3 | |badge4 | |badge5 |
30
30
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.
33
33
34
34
**Table of contents **
35
35
@@ -39,65 +39,64 @@ REST API methods.
39
39
Usage
40
40
=====
41
41
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:
44
44
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;
47
48
49
+ .. code :: python
48
50
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
50
54
55
+ class PingMessage (BaseModel ):
56
+ message: str
51
57
52
- from odoo.addons.base_rest import restapi
53
- from odoo.addons.component.core import Component
54
- from odoo.addons.pydantic.models import BaseModel
55
58
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'
58
64
59
65
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)
75
74
76
75
Bug Tracker
77
76
===========
78
77
79
78
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues >`_.
80
79
In case of trouble, please check there if your issue has already been reported.
81
80
If 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** >`_.
83
82
84
83
Do not contact contributors directly about support or help with technical issues.
85
84
86
85
Credits
87
86
=======
88
87
89
88
Authors
90
- ~~~~~~~
89
+ -------
91
90
92
91
* ACSONE SA/NV
93
92
94
93
Contributors
95
- ~~~~~~~~~~~~
94
+ ------------
96
95
97
- * Laurent Mignon <
[email protected] >
96
+ - Laurent Mignon <
[email protected] >
98
97
99
98
Maintainers
100
- ~~~~~~~~~~~
99
+ -----------
101
100
102
101
This module is maintained by the OCA.
103
102
@@ -109,6 +108,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
109
108
mission is to support the collaborative development of Odoo features and
110
109
promote its widespread use.
111
110
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.
113
112
114
113
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
0 commit comments