Skip to content

Commit 6fd14c7

Browse files
committed
Merge dev into main
2 parents 30741bb + a78ed97 commit 6fd14c7

39 files changed

Lines changed: 2744 additions & 141 deletions

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.15.0-blue)
3+
![Current Release](https://img.shields.io/badge/release-v0.15.5-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)

osbot_fast_api/api/Fast_API.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ def fast_api_utils(self):
112112

113113
return Fast_API_Utils(self.app())
114114

115+
def open_api_json(self):
116+
return self.app().openapi()
117+
115118
def path_static_folder(self): # override this to add support for serving static files from this directory
116119
return None
117120

osbot_fast_api/api/decorators/Fast_API__Thread__Trace_Request.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
2-
import sys
31
from functools import wraps
42
from fastapi import Request
53
from osbot_utils.helpers.trace.Trace_Call import Trace_Call
6-
from osbot_utils.utils.Objects import obj_info
7-
84

95
# this is needed to add support for tracing a request for the FastAPI requests that execute in the threat pool
106
# i.e. any request that doesn't use async in the method definition

osbot_fast_api/api/routes/Fast_API__Routes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from fastapi.exceptions import RequestValidationError
99
from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Cache import type_safe_cache
1010
from osbot_fast_api.api.routes.Fast_API__Route__Parser import Fast_API__Route__Parser
11+
from osbot_fast_api.api.transformers.Type_Safe__To__BaseModel import type_safe__to__basemodel
1112
from osbot_fast_api.schemas.Safe_Str__Fast_API__Route__Prefix import Safe_Str__Fast_API__Route__Prefix
1213
from osbot_fast_api.schemas.Safe_Str__Fast_API__Route__Tag import Safe_Str__Fast_API__Route__Tag
13-
from osbot_fast_api.utils.type_safe.Type_Safe__To__BaseModel import type_safe__to__basemodel
1414

1515

1616
class Fast_API__Routes(Type_Safe): # refactor to Fast_API__Routes
@@ -208,7 +208,7 @@ def wrapper(*args, **kwargs):
208208
})
209209
elif param_name in type_safe_conversions: # Handle Type_Safe params (complex objects in GET)
210210
type_safe_class, _ = type_safe_conversions[param_name] # Get the Type_Safe class
211-
converted_kwargs[param_name] = param_value # Placeholder - needs custom query param parsing
211+
converted_kwargs[param_name] = param_value # todo: question: is this comment this relevant (with current codebase) -> Placeholder - needs custom query param parsing
212212
else:
213213
converted_kwargs[param_name] = param_value # Pass through unchanged
214214

osbot_fast_api/api/routes/Routes__Config.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
from fastapi.responses import HTMLResponse
2-
from osbot_fast_api.api.routes.Fast_API__Routes import Fast_API__Routes
3-
from osbot_fast_api.utils.Fast_API__Routes__Paths import Fast_API__Routes__Paths
4-
from osbot_fast_api.utils.Fast_API__Server_Info import fast_api__server_info
5-
from osbot_fast_api.utils.Version import version__osbot_fast_api
1+
from fastapi import Response
2+
from fastapi.responses import HTMLResponse
3+
from osbot_fast_api.api.decorators.route_path import route_path
4+
from osbot_fast_api.api.routes.Fast_API__Routes import Fast_API__Routes
5+
from osbot_fast_api.api.transformers.OpenAPI__To__Python import OpenAPI__To__Python
6+
from osbot_fast_api.utils.Fast_API__Routes__Paths import Fast_API__Routes__Paths
7+
from osbot_fast_api.utils.Fast_API__Server_Info import fast_api__server_info
8+
from osbot_fast_api.utils.Version import version__osbot_fast_api
69

710

811
class Routes__Config(Fast_API__Routes):
@@ -24,9 +27,18 @@ def routes__html(self):
2427
html_content = Fast_API__Routes__Paths(app=self.app).routes_html()
2528
return HTMLResponse(content=html_content)
2629

30+
@route_path('/openapi.py')
31+
def openapi_python(self):
32+
open_api_to_python = OpenAPI__To__Python()
33+
client_python_code = open_api_to_python.generate_from_app(app=self.app)
34+
35+
return Response(content = client_python_code,
36+
media_type = "text/x-python" )
37+
2738
def setup_routes(self):
28-
self.add_route_get(self.info )
29-
self.add_route_get(self.status )
30-
self.add_route_get(self.version )
31-
self.add_route_get(self.routes__json)
32-
self.add_route_get(self.routes__html)
39+
self.add_route_get(self.info )
40+
self.add_route_get(self.status )
41+
self.add_route_get(self.version )
42+
self.add_route_get(self.routes__json )
43+
self.add_route_get(self.routes__html )
44+
self.add_route_get(self.openapi_python)

0 commit comments

Comments
 (0)