Skip to content

Commit fba3a87

Browse files
committed
Merge dev into main
2 parents 17868cf + 376892c commit fba3a87

8 files changed

Lines changed: 1158 additions & 15 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OSBot-Fast-API
22

3-
![Current Release](https://img.shields.io/badge/release-v0.25.0-blue)
3+
![Current Release](https://img.shields.io/badge/release-v0.25.2-blue)
44
![Python](https://img.shields.io/badge/python-3.8+-green)
55
![FastAPI](https://img.shields.io/badge/FastAPI-0.100+-red)
66
![Type-Safe](https://img.shields.io/badge/Type--Safe-✓-brightgreen)

docs/architecture/v0.25.1__dual-layer-api-contract-pattern.md

Lines changed: 579 additions & 0 deletions
Large diffs are not rendered by default.

osbot_fast_api/api/Fast_API.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from osbot_utils.type_safe.primitives.domains.common.safe_str.Safe_Str__Text import Safe_Str__Text
55
from osbot_utils.type_safe.primitives.domains.common.safe_str.Safe_Str__Version import Safe_Str__Version
66
from osbot_utils.type_safe.primitives.domains.identifiers.Random_Guid import Random_Guid
7+
from osbot_utils.utils.Json import json_loads, json_dumps
78
from starlette.staticfiles import StaticFiles
89
from osbot_fast_api.admin_ui.api.Admin_UI__Config import Admin_UI__Config
910
from osbot_fast_api.api.Fast_API__Offline_Docs import Fast_API__Offline_Docs, FILE_PATH__STATIC__DOCS, URL__STATIC__DOCS, NAME__STATIC__DOCS
@@ -58,7 +59,8 @@ async def http_exception_handler(request: Request, exc: HTTPException):
5859

5960
@app.exception_handler(RequestValidationError)
6061
async def validation_exception_handler(request: Request, exc: RequestValidationError):
61-
return JSONResponse( status_code=400, content={"detail": exc.errors()} )
62+
errors_dict = json_loads(json_dumps(exc.errors(), pretty=False)) # need this round trip to handle the case when exception has non json parseable content (like bytes)
63+
return JSONResponse( status_code=400, content={"detail": errors_dict })
6264

6365

6466
def add_flask_app(self, path, flask_app):

osbot_fast_api/api/routes/Fast_API__Routes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ def wrapper(**kwargs):
104104

105105
try:
106106
result = function(**converted_kwargs) # Call original function
107+
except HTTPException:
108+
raise # Re-raise HTTPException unchanged
109+
except RequestValidationError:
110+
raise # also re-raise RequestValidationError
107111
except Exception as e:
108112
raise HTTPException(status_code=400, detail=f"{type(e).__name__}: {e}") # Convert exceptions to HTTP 400
109113

osbot_fast_api/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.25.0
1+
v0.25.2

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "osbot_fast_api"
3-
version = "v0.25.0"
3+
version = "v0.25.2"
44
description = "OWASP Security Bot - Fast API"
55
authors = ["Dinis Cruz <dinis.cruz@owasp.org>"]
66
license = "MIT"

tests/unit/api/test_Fast_API.py

Lines changed: 568 additions & 10 deletions
Large diffs are not rendered by default.

tests/unit/fast_api__for_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
fast_api_client = fast_api.client()
99

1010
if in_github_action() is False:
11-
assert duration.seconds < 0.2 # make sure that the Fast_API object is created in less than 0.2 seconds
11+
assert duration.seconds < 0.3 # make sure that the Fast_API object is created in less than 0.3 seconds

0 commit comments

Comments
 (0)