Skip to content

Commit 8661e8f

Browse files
committed
skip tags for mount with include_in_schema=False
1 parent 257d79c commit 8661e8f

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

ellar/core/response/model/base.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,14 @@ def _get_model_field_from_schema(
9191
_model_field_or_schema: t.Optional[ResponseModelField] = (
9292
model_field_or_schema or self.model_field_or_schema
9393
)
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
101102

102103
_model_field_or_schema = t.cast(
103104
ResponseModelField,

ellar/core/response/model/html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(
2020
template_name: str,
2121
use_mvc: bool = False,
2222
) -> None:
23-
super().__init__()
23+
super().__init__(model_field_or_schema=str)
2424
self.template_name = template_name
2525
self.use_mvc = use_mvc
2626

ellar/core/routing/router/module.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def controller_router_factory(
3434
routes = reflect.get_metadata(CONTROLLER_OPERATION_HANDLER_KEY, controller) or []
3535
app = Router()
3636
app.routes = ModuleRouteCollection(routes) # type:ignore
37+
include_in_schema = reflect.get_metadata_or_raise_exception(
38+
CONTROLLER_METADATA.INCLUDE_IN_SCHEMA, controller
39+
)
3740
router = ModuleMount(
3841
app=app,
3942
path=reflect.get_metadata_or_raise_exception(
@@ -48,10 +51,7 @@ def controller_router_factory(
4851
guards=reflect.get_metadata_or_raise_exception(
4952
CONTROLLER_METADATA.GUARDS, controller
5053
),
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,
5555
**openapi
5656
)
5757
return router

ellar/openapi/builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def build_document(self, app: App) -> OpenAPI:
206206
for mount in mounts:
207207
if isinstance(mount, ModuleMount):
208208
data = mount.get_tag()
209-
if data:
209+
if data and mount.include_in_schema:
210210
self._build.setdefault("tags", []).append(data)
211211
if components:
212212
self._build.setdefault("components", {}).update(components)

0 commit comments

Comments
 (0)