File tree Expand file tree Collapse file tree 4 files changed +14
-13
lines changed Expand file tree Collapse file tree 4 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -91,13 +91,14 @@ def _get_model_field_from_schema(
91
91
_model_field_or_schema : t .Optional [ResponseModelField ] = (
92
92
model_field_or_schema or self .model_field_or_schema
93
93
)
94
- if _model_field_or_schema and not isinstance (
95
- _model_field_or_schema , ResponseModelField
96
- ):
97
- # convert to serializable type of base `Class BaseSerializer`
98
- new_response_schema = ResponseTypeDefinitionConverter (
99
- _model_field_or_schema
100
- ).re_group_outer_type ()
94
+ if not isinstance (_model_field_or_schema , ResponseModelField ):
95
+ try :
96
+ # convert to serializable type of base `Class BaseSerializer` is possible
97
+ new_response_schema = ResponseTypeDefinitionConverter (
98
+ _model_field_or_schema
99
+ ).re_group_outer_type ()
100
+ except Exception :
101
+ new_response_schema = _model_field_or_schema
101
102
102
103
_model_field_or_schema = t .cast (
103
104
ResponseModelField ,
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ def __init__(
20
20
template_name : str ,
21
21
use_mvc : bool = False ,
22
22
) -> None :
23
- super ().__init__ ()
23
+ super ().__init__ (model_field_or_schema = str )
24
24
self .template_name = template_name
25
25
self .use_mvc = use_mvc
26
26
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ def controller_router_factory(
34
34
routes = reflect .get_metadata (CONTROLLER_OPERATION_HANDLER_KEY , controller ) or []
35
35
app = Router ()
36
36
app .routes = ModuleRouteCollection (routes ) # type:ignore
37
+ include_in_schema = reflect .get_metadata_or_raise_exception (
38
+ CONTROLLER_METADATA .INCLUDE_IN_SCHEMA , controller
39
+ )
37
40
router = ModuleMount (
38
41
app = app ,
39
42
path = reflect .get_metadata_or_raise_exception (
@@ -48,10 +51,7 @@ def controller_router_factory(
48
51
guards = reflect .get_metadata_or_raise_exception (
49
52
CONTROLLER_METADATA .GUARDS , controller
50
53
),
51
- include_in_schema = reflect .get_metadata_or_raise_exception (
52
- CONTROLLER_METADATA .INCLUDE_IN_SCHEMA , controller
53
- )
54
- or True ,
54
+ include_in_schema = include_in_schema if include_in_schema is not None else True ,
55
55
** openapi
56
56
)
57
57
return router
Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ def build_document(self, app: App) -> OpenAPI:
206
206
for mount in mounts :
207
207
if isinstance (mount , ModuleMount ):
208
208
data = mount .get_tag ()
209
- if data :
209
+ if data and mount . include_in_schema :
210
210
self ._build .setdefault ("tags" , []).append (data )
211
211
if components :
212
212
self ._build .setdefault ("components" , {}).update (components )
You can’t perform that action at this time.
0 commit comments