ohmyapi 0.1.21__py3-none-any.whl → 0.1.22__py3-none-any.whl
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.
- ohmyapi/core/templates/app/routes.py.j2 +31 -7
- ohmyapi/router.py +2 -0
- {ohmyapi-0.1.21.dist-info → ohmyapi-0.1.22.dist-info}/METADATA +67 -24
- {ohmyapi-0.1.21.dist-info → ohmyapi-0.1.22.dist-info}/RECORD +6 -6
- {ohmyapi-0.1.21.dist-info → ohmyapi-0.1.22.dist-info}/WHEEL +0 -0
- {ohmyapi-0.1.21.dist-info → ohmyapi-0.1.22.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,8 @@
|
|
1
|
-
from ohmyapi.router import APIRouter
|
1
|
+
from ohmyapi.router import APIRouter, HTTPException, HTTPStatus
|
2
2
|
|
3
|
-
from .
|
3
|
+
from . import models
|
4
|
+
|
5
|
+
from typing import List
|
4
6
|
|
5
7
|
# Expose your app's routes via `router = fastapi.APIRouter`.
|
6
8
|
# Use prefixes wisely to avoid cross-app namespace-collisions.
|
@@ -8,10 +10,32 @@ from .models import ...
|
|
8
10
|
router = APIRouter(prefix="/{{ app_name }}", tags=['{{ app_name }}'])
|
9
11
|
|
10
12
|
|
13
|
+
|
11
14
|
@router.get("/")
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
async def list():
|
16
|
+
"""List all ..."""
|
17
|
+
return []
|
18
|
+
|
19
|
+
|
20
|
+
@router.post("/")
|
21
|
+
async def post():
|
22
|
+
"""Create ..."""
|
23
|
+
return HTTPException(status_code=HTTPStatus.CREATED)
|
24
|
+
|
25
|
+
|
26
|
+
@router.get("/{id}")
|
27
|
+
async def get(id: str):
|
28
|
+
"""Get single ..."""
|
29
|
+
return {}
|
30
|
+
|
31
|
+
|
32
|
+
@router.put("/{id}")
|
33
|
+
async def put(id: str):
|
34
|
+
"""Update ..."""
|
35
|
+
return HTTPException(status_code=HTTPStatus.ACCEPTED)
|
36
|
+
|
37
|
+
|
38
|
+
@router.delete("/{id}")
|
39
|
+
async def delete(id: str):
|
40
|
+
return HTTPException(status_code=HTTPStatus.ACCEPTED)
|
17
41
|
|
ohmyapi/router.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ohmyapi
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.22
|
4
4
|
Summary: A Django-like but async web-framework based on FastAPI and TortoiseORM.
|
5
5
|
License-Expression: MIT
|
6
6
|
Keywords: fastapi,tortoise,orm,async,web-framework
|
@@ -157,7 +157,7 @@ class Team(Model):
|
|
157
157
|
Next, create your endpoints in `tournament/routes.py`:
|
158
158
|
|
159
159
|
```python
|
160
|
-
from ohmyapi.router import APIRouter, HTTPException
|
160
|
+
from ohmyapi.router import APIRouter, HTTPException, HTTPStatus
|
161
161
|
from ohmyapi.db.exceptions import DoesNotExist
|
162
162
|
|
163
163
|
from .models import Tournament
|
@@ -167,20 +167,25 @@ from .models import Tournament
|
|
167
167
|
# Tags improve the UX of the OpenAPI docs at /docs.
|
168
168
|
router = APIRouter(prefix="/tournament", tags=['Tournament'])
|
169
169
|
|
170
|
-
|
171
170
|
@router.get("/")
|
172
171
|
async def list():
|
173
172
|
queryset = Tournament.all()
|
174
173
|
return await Tournament.Schema.model.from_queryset(queryset)
|
175
174
|
|
176
175
|
|
176
|
+
@router.post("/", status_code=HTTPStatus.CREATED)
|
177
|
+
async def post(tournament: Tournament.Schema.readonly):
|
178
|
+
queryset = Tournament.create(**payload.model_dump())
|
179
|
+
return await Tournament.Schema.model.from_queryset(queryset)
|
180
|
+
|
181
|
+
|
177
182
|
@router.get("/:id")
|
178
183
|
async def get(id: str):
|
179
184
|
try:
|
180
|
-
|
185
|
+
queryset = Tournament.get(id=id)
|
181
186
|
return await Tournament.Schema.model.from_queryset_single(tournament)
|
182
187
|
except DoesNotExist:
|
183
|
-
raise HTTPException(status_code=404, detail="
|
188
|
+
raise HTTPException(status_code=404, detail="not found")
|
184
189
|
|
185
190
|
...
|
186
191
|
```
|
@@ -350,28 +355,66 @@ Find your loaded project singleton via identifier: `p`
|
|
350
355
|
|
351
356
|
```python
|
352
357
|
In [1]: p
|
353
|
-
Out[1]: <ohmyapi.core.runtime.Project at
|
358
|
+
Out[1]: <ohmyapi.core.runtime.Project at 0x7f00c43dbcb0>
|
354
359
|
|
355
360
|
In [2]: p.apps
|
356
361
|
Out[2]:
|
357
|
-
{'ohmyapi_auth':
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
362
|
+
{'ohmyapi_auth': {
|
363
|
+
"models": [
|
364
|
+
"Group",
|
365
|
+
"User"
|
366
|
+
],
|
367
|
+
"routes": [
|
368
|
+
{
|
369
|
+
"path": "/auth/login",
|
370
|
+
"name": "login",
|
371
|
+
"methods": [
|
372
|
+
"POST"
|
373
|
+
],
|
374
|
+
"endpoint": "login",
|
375
|
+
"response_model": null,
|
376
|
+
"tags": [
|
377
|
+
"auth"
|
378
|
+
]
|
379
|
+
},
|
380
|
+
{
|
381
|
+
"path": "/auth/refresh",
|
382
|
+
"name": "refresh_token",
|
383
|
+
"methods": [
|
384
|
+
"POST"
|
385
|
+
],
|
386
|
+
"endpoint": "refresh_token",
|
387
|
+
"response_model": null,
|
388
|
+
"tags": [
|
389
|
+
"auth"
|
390
|
+
]
|
391
|
+
},
|
392
|
+
{
|
393
|
+
"path": "/auth/introspect",
|
394
|
+
"name": "introspect",
|
395
|
+
"methods": [
|
396
|
+
"GET"
|
397
|
+
],
|
398
|
+
"endpoint": "introspect",
|
399
|
+
"response_model": null,
|
400
|
+
"tags": [
|
401
|
+
"auth"
|
402
|
+
]
|
403
|
+
},
|
404
|
+
{
|
405
|
+
"path": "/auth/me",
|
406
|
+
"name": "me",
|
407
|
+
"methods": [
|
408
|
+
"GET"
|
409
|
+
],
|
410
|
+
"endpoint": "me",
|
411
|
+
"response_model": null,
|
412
|
+
"tags": [
|
413
|
+
"auth"
|
414
|
+
]
|
415
|
+
}
|
416
|
+
]
|
417
|
+
}}
|
375
418
|
```
|
376
419
|
|
377
420
|
|
@@ -10,7 +10,7 @@ ohmyapi/core/runtime.py,sha256=i4dI7mC59rw0blMOeVGawUm8v5id3ZllLlP8RLo1GT0,9419
|
|
10
10
|
ohmyapi/core/scaffolding.py,sha256=SA0SYFd7VcqkOn9xuXgj-yOoVqCZMJo68GGFbm34GE4,2663
|
11
11
|
ohmyapi/core/templates/app/__init__.py.j2,sha256=QwVIQVUGZVhdH1d4NrvL7NTsK4-T4cihzYs8UVX2dt4,43
|
12
12
|
ohmyapi/core/templates/app/models.py.j2,sha256=_3w-vFJ5fgsmncsCv34k_wyCMF78jufbSSglns4gbb0,119
|
13
|
-
ohmyapi/core/templates/app/routes.py.j2,sha256=
|
13
|
+
ohmyapi/core/templates/app/routes.py.j2,sha256=dFpmfrfN1pwOsD6MAa_MmI7aP4kKJ2ZiijobWHsfyDs,873
|
14
14
|
ohmyapi/core/templates/project/README.md.j2,sha256=SjR4JIrg-8XRE-UntUDwiw8jDpYitD_UjwoKkYJ7GLw,22
|
15
15
|
ohmyapi/core/templates/project/pyproject.toml.j2,sha256=X0VS6YT9aL3vpHFKPTfLFsdpD8423nY57ySQpSTMxmQ,895
|
16
16
|
ohmyapi/core/templates/project/settings.py.j2,sha256=RBKGB8MZWPM3Bp0a57Y1YrSvSXxh502TUnJqbbu48Ig,138
|
@@ -18,8 +18,8 @@ ohmyapi/db/__init__.py,sha256=5QKUycxnN83DOUD_Etoee9tEOYjnZ74deqrSOOx_MiQ,204
|
|
18
18
|
ohmyapi/db/exceptions.py,sha256=vb4IIUoeYAY6sK42zRtjMy-39IFVi_Qb6mWySTY0jYw,34
|
19
19
|
ohmyapi/db/model/__init__.py,sha256=k3StTNuKatpwZo_Z5JBFa-927eJrzibFE8U4SA82asc,32
|
20
20
|
ohmyapi/db/model/model.py,sha256=WTf41ByCtfk9c_O6QCsO9KA0avHL3zGMZ6SEdw5GOuc,2420
|
21
|
-
ohmyapi/router.py,sha256=
|
22
|
-
ohmyapi-0.1.
|
23
|
-
ohmyapi-0.1.
|
24
|
-
ohmyapi-0.1.
|
25
|
-
ohmyapi-0.1.
|
21
|
+
ohmyapi/router.py,sha256=LDxOyiqSb5zVU9zCxi014Ad4DKPZn6V8o9u0WfpmgdE,83
|
22
|
+
ohmyapi-0.1.22.dist-info/METADATA,sha256=NrxMn9DH5ydLr6Aui5yN4svdRP9UiuKT5GqzJ8XMuaU,9727
|
23
|
+
ohmyapi-0.1.22.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
|
24
|
+
ohmyapi-0.1.22.dist-info/entry_points.txt,sha256=wb3lw8-meAlpiv1mqcQ3m25ukL7djagU_w89GkrC37k,43
|
25
|
+
ohmyapi-0.1.22.dist-info/RECORD,,
|
File without changes
|
File without changes
|