Skip to content

Commit cb6eb1b

Browse files
committed
Modified Swagger setup and adpoted the new module config settings
1 parent d43a58c commit cb6eb1b

4 files changed

Lines changed: 22 additions & 13 deletions

File tree

ellar_cli/main.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ellar.commands import EllarTyper
77
from ellar.constants import CALLABLE_COMMAND_INFO, MODULE_METADATA
88
from ellar.core.factory import AppFactory
9+
from ellar.core.modules import ModuleSetup
910
from ellar.services import Reflector
1011
from typer import Typer
1112
from typer.models import CommandInfo
@@ -59,11 +60,15 @@ def build_typers() -> t.Any:
5960
meta_: t.Optional[EllarCLIService] = EllarCLIService.import_project_meta(app_name)
6061

6162
if meta_ and meta_.has_meta:
62-
modules = AppFactory.get_all_modules(meta_.import_root_module())
63+
module_configs = AppFactory.get_all_modules(
64+
ModuleSetup(meta_.import_root_module())
65+
)
6366
reflector = Reflector()
6467

65-
for module in modules:
66-
typers_commands = reflector.get(MODULE_METADATA.COMMANDS, module) or []
68+
for module_config in module_configs:
69+
typers_commands = (
70+
reflector.get(MODULE_METADATA.COMMANDS, module_config.module) or []
71+
)
6772
for typer_command in typers_commands:
6873
if isinstance(typer_command, EllarTyper):
6974
_typer.add_typer(typer_command)

ellar_cli/scaffolding/module_template/module_name/controllers.ellar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ from ellar.core import ControllerBase
1414

1515
@Controller
1616
class {{module_name | capitalize}}Controller(ControllerBase):
17+
1718
@get("/")
1819
def index(self):
1920
return {"detail": "Welcome {{module_name | capitalize}} Resource"}
20-

ellar_cli/scaffolding/module_template/module_name/module.ellar

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ from .controllers import {{module_name | capitalize}}Controller
3030
routers=[],
3131
)
3232
class {{module_name | capitalize}}Module(ModuleBase):
33-
def register_providers(self, container: Container) -> None:
34-
# for more complicated provider registrations
35-
# container.register_instance(...)
36-
pass
33+
"""
34+
{{module_name | capitalize}} Module
35+
"""
3736

37+
def register_providers(self, container: Container) -> None:
38+
"""for more complicated provider registrations, use container.register_instance(...) """

ellar_cli/scaffolding/project_template/project_name/server.ellar

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import os
22

33
from ellar.constants import ELLAR_CONFIG_MODULE
44
from ellar.core.factory import AppFactory
5-
# from ellar.openapi import OpenAPIDocumentModule, OpenAPIDocumentBuilder
5+
# from ellar.openapi import OpenAPIDocumentModule, OpenAPIDocumentBuilder, SwaggerDocumentGenerator
66
from .root_module import ApplicationModule
77

88
application = AppFactory.create_from_app_module(
@@ -21,7 +21,10 @@ application = AppFactory.create_from_app_module(
2121
# .set_contact(name='Author Name', url='https://www.author-name.com', email='authorname@gmail.com') \
2222
# .set_license('MIT Licence', url='https://www.google.com')
2323
#
24-
# document = document_builder.build_document(app)
25-
# module = application.install_module(OpenAPIDocumentModule, document=document)
26-
# module.setup_swagger_doc()
27-
24+
# document = document_builder.build_document(application)
25+
# module = OpenAPIDocumentModule.setup(
26+
# document=document,
27+
# document_generator=SwaggerDocumentGenerator(),
28+
# guards=[]
29+
# )
30+
# application.install_module(module)

0 commit comments

Comments
 (0)