Maintainers
+Maintainers
This module is maintained by the OCA.
@@ -772,6 +767,5 @@ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8d5b36e76..8b7b498eb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: | (?x) # NOT INSTALLABLE ADDONS - ^extendable/| + ^fastapi_auth_jwt_demo/| # END NOT INSTALLABLE ADDONS # Files and folders generated by bots, to avoid loops ^setup/|/static/description/index\.html$| diff --git a/base_rest/README.rst b/base_rest/README.rst index 5f93be562..2dad8464f 100644 --- a/base_rest/README.rst +++ b/base_rest/README.rst @@ -1,7 +1,3 @@ -.. image:: https://odoo-community.org/readme-banner-image - :target: https://odoo-community.org/get-involved?utm_source=readme - :alt: Odoo Community Association - ========= Base Rest ========= @@ -17,7 +13,7 @@ Base Rest .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github diff --git a/base_rest/__manifest__.py b/base_rest/__manifest__.py index f52490813..584dae570 100644 --- a/base_rest/__manifest__.py +++ b/base_rest/__manifest__.py @@ -20,8 +20,7 @@ "assets": { "web.assets_frontend": [ "base_rest/static/src/scss/base_rest.scss", - "base_rest/static/src/js/swagger_ui.js", - "base_rest/static/src/js/swagger.js", + "base_rest/static/src/js/components/swagger_ui.esm.js", ], }, "external_dependencies": { diff --git a/base_rest/static/description/index.html b/base_rest/static/description/index.html index 11068ef2a..b7b999a91 100644 --- a/base_rest/static/description/index.html +++ b/base_rest/static/description/index.html @@ -3,7 +3,7 @@
-This addon is deprecated and not fully supported anymore from Odoo 16. Please migrate to the FastAPI migration module. See https://github.com/OCA/rest-framework/pull/291.
@@ -414,7 +409,7 @@If an error occurs when calling a method of a service (ie missing parameter, ..) the system returns only a general description of the problem without details. This is done on purpose to ensure maximum @@ -436,7 +431,7 @@
To add your own REST service you must provides at least 2 classes.
-from odoo.addons.component.core import Component +from odoo.addons.component.core import Component -class PingService(Component): +class PingService(Component): _inherit = 'base.rest.service' _name = 'ping.service' _usage = 'ping' @@ -477,37 +472,37 @@Usage
# The following method are 'public' and can be called from the controller. - def get(self, _id, message): + def get(self, _id, message): return { 'response': 'Get called with message ' + message} - def search(self, message): + def search(self, message): return { 'response': 'Search called search with message ' + message} - def update(self, _id, message): + def update(self, _id, message): return {'response': 'PUT called with message ' + message} # pylint:disable=method-required-super - def create(self, **params): + def create(self, **params): return {'response': 'POST called with message ' + params['message']} - def delete(self, _id): + def delete(self, _id): return {'response': 'DELETE called with id %s ' % _id} # Validator - def _validator_search(self): + def _validator_search(self): return {'message': {'type': 'string'}} # Validator - def _validator_get(self): + def _validator_get(self): # no parameters by default return {} - def _validator_update(self): + def _validator_update(self): return {'message': {'type': 'string'}} - def _validator_create(self): + def _validator_create(self): return {'message': {'type': 'string'}}
Once you have implemented your services (ping, …), you must tell to @@ -515,9 +510,9 @@
-from odoo.addons.base_rest.controllers import main +from odoo.addons.base_rest.controllers import main -class MyRestController(main.RestController): +class MyRestController(main.RestController): _root_path = '/my_services_api/' _collection_name = my_module.services@@ -533,7 +528,7 @@
As result an HTTP GET call to ‘http://my_odoo/my_services_api/ping’ will @@ -583,7 +578,7 @@
-class PartnerNewApiService(Component): +class PartnerNewApiService(Component): _inherit = "base.rest.service" _name = "partner.new_api.service" _usage = "partner" @@ -598,10 +593,10 @@@@ -620,28 +615,28 @@Usage
output_param=restapi.CerberusValidator("_get_partner_schema"), auth="public", ) - def get(self, _id): + def get(self, _id): return {"name": self.env["res.partner"].browse(_id).name} - def _get_partner_schema(self): + def _get_partner_schema(self): return { "name": {"type": "string", "required": True} } @@ -611,7 +606,7 @@Usage
output_param=restapi.CerberusListValidator("_get_partner_schema"), auth="public", ) - def list(self): + def list(self): partners = self.env["res.partner"].search([]) return [{"name": p.name} for p in partners]
-from marshmallow import fields +from marshmallow import fields -from odoo.addons.base_rest import restapi -from odoo.addons.component.core import Component -from odoo.addons.datamodel.core import Datamodel +from odoo.addons.base_rest import restapi +from odoo.addons.component.core import Component +from odoo.addons.datamodel.core import Datamodel -class PartnerSearchParam(Datamodel): +class PartnerSearchParam(Datamodel): _name = "partner.search.param" id = fields.Integer(required=False, allow_none=False) name = fields.String(required=False, allow_none=False) -class PartnerShortInfo(Datamodel): +class PartnerShortInfo(Datamodel): _name = "partner.short.info" id = fields.Integer(required=True, allow_none=False) name = fields.String(required=True, allow_none=False) -class PartnerNewApiService(Component): +class PartnerNewApiService(Component): _inherit = "base.rest.service" _name = "partner.new_api.service" _usage = "partner" @@ -657,7 +652,7 @@Usage
output_param=restapi.Datamodel("partner.short.info", is_list=True), auth="public", ) - def search(self, partner_search_param): + def search(self, partner_search_param): """ Search for partners :param partner_search_param: An instance of partner.search.param @@ -683,7 +678,7 @@Usage
evaluation context.
The
roadmap
and known
@@ -691,9 +686,9 @@ Known issues / Roadmap
can be found on GitHub.
Features
First official version. The addon has been incubated into the Shopinvader repository from @@ -736,7 +731,7 @@
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed @@ -744,22 +739,22 @@
Do not contact contributors directly about support or help with technical issues.