ohmyapi 0.2.4__tar.gz → 0.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/PKG-INFO +1 -1
  2. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/pyproject.toml +14 -1
  3. ohmyapi-0.2.7/src/ohmyapi/__init__.py +1 -0
  4. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/cli.py +1 -0
  5. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/core/runtime.py +33 -14
  6. ohmyapi-0.2.4/src/ohmyapi/__init__.py +0 -1
  7. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/README.md +0 -0
  8. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/__main__.py +0 -0
  9. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/builtin/auth/__init__.py +0 -0
  10. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/builtin/auth/models.py +0 -0
  11. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/builtin/auth/permissions.py +0 -0
  12. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/builtin/auth/routes.py +0 -0
  13. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/builtin/demo/__init__.py +0 -0
  14. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/builtin/demo/models.py +0 -0
  15. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/builtin/demo/routes.py +0 -0
  16. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/core/__init__.py +0 -0
  17. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/core/scaffolding.py +0 -0
  18. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/core/templates/app/__init__.py.j2 +0 -0
  19. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/core/templates/app/models.py.j2 +0 -0
  20. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/core/templates/app/routes.py.j2 +0 -0
  21. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/core/templates/project/README.md.j2 +0 -0
  22. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/core/templates/project/pyproject.toml.j2 +0 -0
  23. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/core/templates/project/settings.py.j2 +0 -0
  24. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/db/__init__.py +0 -0
  25. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/db/exceptions.py +0 -0
  26. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/db/model/__init__.py +0 -0
  27. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/db/model/model.py +0 -0
  28. {ohmyapi-0.2.4 → ohmyapi-0.2.7}/src/ohmyapi/router.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ohmyapi
3
- Version: 0.2.4
3
+ Version: 0.2.7
4
4
  Summary: Django-flavored scaffolding and management layer around FastAPI, Pydantic, TortoiseORM and Aerich migrations
5
5
  License-Expression: MIT
6
6
  Keywords: fastapi,tortoise,orm,pydantic,async,web-framework
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ohmyapi"
3
- version = "0.2.4"
3
+ version = "0.2.7"
4
4
  description = "Django-flavored scaffolding and management layer around FastAPI, Pydantic, TortoiseORM and Aerich migrations"
5
5
  license = "MIT"
6
6
  keywords = ["fastapi", "tortoise", "orm", "pydantic", "async", "web-framework"]
@@ -43,6 +43,19 @@ ohmyapi = "ohmyapi.cli:app"
43
43
  [project.urls]
44
44
  repository = "https://code.c-base.org/baccenfutter/ohmyapi"
45
45
 
46
+ [build-system]
47
+ requires = [
48
+ "poetry-core>=1.8.0",
49
+ "poetry-dynamic-versioning>=1.8.0"
50
+ ]
51
+ build-backend = "poetry_dynamic_versioning.backend"
52
+
53
+ [tool.poetry-dynamic-versioning]
54
+ enable = true
55
+ source = "file"
56
+ path = "src/ohmyapi/__init__.py"
57
+ pattern = "__VERSION__\\s*=\\s*['\"](?P<version>[^'\"]+)['\"]"
58
+
46
59
  [tool.black]
47
60
  line-length = 88
48
61
  target-version = ['py39', 'py310', 'py311', 'py312', 'py313']
@@ -0,0 +1 @@
1
+ __VERSION__ = "0.2.7"
@@ -35,6 +35,7 @@ def serve(root: str = ".", host="127.0.0.1", port=8000):
35
35
  project_path = Path(root)
36
36
  project = runtime.Project(project_path)
37
37
  app_instance = project.app()
38
+ app_instance = project.configure_app(app_instance)
38
39
  uvicorn.run(app_instance, host=host, port=int(port), reload=False)
39
40
 
40
41
 
@@ -72,23 +72,35 @@ class Project:
72
72
  def is_app_installed(self, name: str) -> bool:
73
73
  return name in getattr(self.settings, "INSTALLED_APPS", [])
74
74
 
75
- def app(self, generate_schemas: bool = False) -> FastAPI:
75
+ def app(self,
76
+ docs_url: str = "/docs",
77
+ ) -> FastAPI:
76
78
  """
77
- Create a FastAPI app, attach all APIRouters from registered apps,
78
- and register ORM lifecycle event handlers.
79
+ Create and return a FastAPI app.
79
80
  """
80
- app = FastAPI(title=getattr(self.settings, "PROJECT_NAME", "OhMyAPI Project"))
81
+ import ohmyapi
82
+ return FastAPI(
83
+ title=getattr(self.settings, "PROJECT_NAME", "OhMyAPI Project"),
84
+ description=getattr(self.settings, "PROJECT_DESCRIPTION", ""),
85
+ docs_url=getattr(self.settings, "DOCS_URL", "/docs"),
86
+ version=ohmyapi.__VERSION__,
87
+ )
81
88
 
82
- # Attach routers from apps
89
+ def configure_app(self, app: FastAPI) -> FastAPI:
90
+ """
91
+ Attach project routes and event handlers to given FastAPI instance.
92
+ """
93
+ # Attach project routes.
83
94
  for app_name, app_def in self._apps.items():
84
- if app_def.router:
85
- app.include_router(app_def.router)
95
+ for router in app_def.routers:
96
+ app.include_router(router)
86
97
 
87
- # Startup / shutdown events
98
+ # Initialize ORM on startup
88
99
  @app.on_event("startup")
89
100
  async def _startup():
90
- await self.init_orm(generate_schemas=generate_schemas)
101
+ await self.init_orm(generate_schemas=False)
91
102
 
103
+ # Close ORM on shutdown
92
104
  @app.on_event("shutdown")
93
105
  async def _shutdown():
94
106
  await self.close_orm()
@@ -333,16 +345,23 @@ class App:
333
345
  module: out,
334
346
  }
335
347
 
348
+ @property
349
+ def routers(self):
350
+ out = []
351
+ for routes_mod in self._routers:
352
+ for r in self._routers[routes_mod]:
353
+ out.append(r)
354
+ return out
355
+
336
356
  @property
337
357
  def routes(self):
338
358
  """
339
359
  Return an APIRouter with all loaded routes.
340
360
  """
341
- router = APIRouter()
342
- for routes_mod in self._routers:
343
- for r in self._routers[routes_mod]:
344
- router.include_router(r)
345
- return router.routes
361
+ out = []
362
+ for r in self.routers:
363
+ out.extend(r.routes)
364
+ return out
346
365
 
347
366
  def dict(self) -> Dict[str, Any]:
348
367
  """
@@ -1 +0,0 @@
1
- from . import db
File without changes
File without changes
File without changes