Skip to content

Commit a5bae2b

Browse files
committed
[MIG] fastapi_auth_api_key: Migration to 18.0
status.HTTP_422_UNPROCESSABLE_ENTITY is deprecated
1 parent 41a4cfc commit a5bae2b

7 files changed

Lines changed: 10 additions & 9 deletions

File tree

fastapi/error_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def convert_exception_to_status_body(exc: Exception) -> tuple[int, dict]:
2929
status_code = exc.status_code
3030
details = exc.detail
3131
elif isinstance(exc, RequestValidationError):
32-
status_code = status.HTTP_422_UNPROCESSABLE_ENTITY
32+
status_code = status.HTTP_422_UNPROCESSABLE_CONTENT
3333
details = jsonable_encoder(exc.errors())
3434
elif isinstance(exc, WebSocketRequestValidationError):
3535
status_code = status.WS_1008_POLICY_VIOLATION

fastapi/tests/test_fastapi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ def test_request_validation_error(self) -> None:
156156
route = "/fastapi_demo/demo/exception?exception_type=BAD&error_message="
157157
response = self.url_open(route, timeout=200)
158158
mocked_commit.assert_not_called()
159-
self.assertEqual(response.status_code, status.HTTP_422_UNPROCESSABLE_ENTITY)
159+
self.assertEqual(
160+
response.status_code, status.HTTP_422_UNPROCESSABLE_CONTENT
161+
)
160162

161163
def test_no_commit_on_exception(self) -> None:
162164
# this test check that the way we mock the cursor is working as expected

fastapi_auth_api_key/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Contributors
101101
Other credits
102102
-------------
103103

104-
The migration of this module from 16.0 to 17.0 was financially supported
104+
The migration of this module from 17.0 to 18.0 was financially supported
105105
by Camptocamp
106106

107107
Maintainers

fastapi_auth_api_key/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{
55
"name": "Fastapi Auth API Key",
6-
"version": "17.0.1.0.0",
6+
"version": "18.0.1.0.0",
77
"category": "Others",
88
"website": "https://github.com/OCA/rest-framework",
99
"author": "Camptocamp, Odoo Community Association (OCA)",

fastapi_auth_api_key/dependencies.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
from typing import Annotated
55

6-
from odoo import SUPERUSER_ID, _
6+
from odoo import SUPERUSER_ID
77
from odoo.api import Environment
88
from odoo.exceptions import ValidationError
99

@@ -27,7 +27,7 @@ def authenticated_auth_api_key(
2727
if not key:
2828
raise HTTPException(
2929
status_code=status.HTTP_401_UNAUTHORIZED,
30-
detail=_("Missing %(HTTP_API_KEY_HEADER)s header")
30+
detail=env._("Missing %(HTTP_API_KEY_HEADER)s header")
3131
% {"HTTP_API_KEY_HEADER": HTTP_API_KEY_HEADER},
3232
headers={"WWW-Authenticate": HTTP_API_KEY_HEADER},
3333
)
@@ -47,7 +47,7 @@ def authenticated_auth_api_key(
4747
):
4848
raise HTTPException(
4949
status_code=status.HTTP_401_UNAUTHORIZED,
50-
detail=_("Unauthorized"),
50+
detail=env._("Unauthorized"),
5151
headers={"WWW-Authenticate": HTTP_API_KEY_HEADER},
5252
)
5353
return auth_api_key
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
The migration of this module from 16.0 to 17.0 was financially supported
1+
The migration of this module from 17.0 to 18.0 was financially supported
22
by Camptocamp

fastapi_auth_api_key/static/description/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>

0 commit comments

Comments
 (0)