Skip to content

Commit 70f91a3

Browse files
authored
UploadFile as alias to DataUpload (#353)
* UploadFile as alias to DataUpload * Fix OpenAPI requestBody * Update internals of directives * Update docs
1 parent 709b07b commit 70f91a3

30 files changed

Lines changed: 247 additions & 152 deletions

docs/en/docs/contrib/openapi.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,7 @@ The `OpenAPIConfig` model encapsulates all settings that control how Lilya gener
422422
* **Description**: A longer, more detailed description for `info.description`. This field supports Markdown formatting and can cover architecture, usage notes, or any high‐level explanation.
423423
* **Type**: `str` (nullable)
424424
* **Default**: `"Yet another framework/toolkit that delivers."`
425-
* **Usage**:
426-
427-
* Renders in the expanded “Info” panel of Swagger UI or as introductory text in ReDoc.
425+
* **Usage**: Renders in the expanded “Info” panel of Swagger UI or as introductory text in ReDoc.
428426

429427
---
430428

docs/en/docs/directives/directives.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,7 @@ You should have a folder called `myproject` with a similar structure to this:
122122
│   │   ├── __init__.py
123123
│   │   └── test_app.py
124124
│   └── urls.py
125-
└── requirements
126-
├── base.txt
127-
├── development.txt
128-
└── testing.txt
129-
125+
└── pyproject.toml
130126
```
131127

132128
A lot of files generated right? Yes but those are actually quite simple but let's talk about what is happening there.
@@ -136,7 +132,7 @@ peoject locally, for example:
136132
* `task run` - Starts your project with the development settings.
137133
* `make test` - Runs your local tests with the testing settings.
138134
* `task clean` - Removes all the `*.pyc` from your project.
139-
* `task requirements` - Installs the mininum requirements from the `requirements` folder.
135+
* `task requirements` - Installs the minimum requirements from the `pyproject.toml`.
140136

141137
!!! Info
142138
The tests are using [pytest](https://docs.pytest.org/) but you can change to whatever you want.

docs/en/docs/release-notes.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ hide:
77

88
## 0.23.3
99

10+
### Added
11+
12+
- `lilya.datastructures` now supports UploadFile as an alias to DataUpload.
13+
- `@openapi` decorator now accepts the `request_body` as parameter and fixes an issue of getting from responses.
14+
15+
### Changed
16+
17+
- Lilya now using the `createproject` directive instead of generating a requirements folder, generates a `pyproject.toml`
18+
instead. This follows the new Python requirements conventions.
19+
1020
### Fixed
1121

1222
- `lilya createdeployment` directive files (nginx and docker) updated to the latest stable versions.

docs_src/openapi/examples/all_in.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from lilya.contrib.openapi.datastructures import OpenAPIResponse
66
from pydantic import BaseModel
77

8+
89
# Pydantic models
910
class Item(BaseModel):
1011
id: int
@@ -24,41 +25,46 @@ class Person(BaseModel):
2425
"limit": Query(default=5, schema={"type": "integer"}, description="Max items"),
2526
"tags": Query(
2627
default=[],
27-
schema={"type":"array","items":{"type":"string"}},
28+
schema={"type": "array", "items": {"type": "string"}},
2829
style="form",
2930
explode=True,
30-
description="Tags filter"
31-
)
31+
description="Tags filter",
32+
),
3233
},
3334
responses={
3435
200: OpenAPIResponse(model=[Item], description="Array of Item"),
35-
404: OpenAPIResponse(model=Person, description="User not found")
36+
404: OpenAPIResponse(model=Person, description="User not found"),
3637
},
3738
tags=["items", "users"],
38-
security=[{"BearerAuth": {"type": "http", "scheme": "bearer", "bearerFormat": "JWT"}}],
39+
security=[
40+
{"BearerAuth": {"type": "http", "scheme": "bearer", "bearerFormat": "JWT"}}
41+
],
3942
)
40-
async def list_user_items(request, user_id: str):
41-
...
43+
async def list_user_items(request, user_id: str): ...
4244

4345

44-
@openapi(summary="Create a new item")
45-
async def create_item(request, user_id: str):
46-
...
46+
@openapi(
47+
summary="Create a new item",
48+
request_body=Item,
49+
)
50+
async def create_item(request, user_id: str, item: Item): ...
4751

4852

4953
# Build app with nested includes and a child app
50-
child = ChildLilya(routes=[
51-
Path("/profile", list_user_items)
52-
], enable_openapi=True)
54+
child = ChildLilya(routes=[Path("/profile", list_user_items)], enable_openapi=True)
5355

5456

55-
app = Lilya(routes=[
56-
Include("/users", routes=[
57-
Path("/{user_id}/items", list_user_items),
58-
Path("/{user_id}/items/create", create_item),
59-
Include("/extra", routes=[
60-
Path("/{user_id}/extra-info", create_item)
61-
])
62-
]),
63-
Include("/account", app=child)
64-
], enable_openapi=True)
57+
app = Lilya(
58+
routes=[
59+
Include(
60+
"/users",
61+
routes=[
62+
Path("/{user_id}/items", list_user_items),
63+
Path("/{user_id}/items/create", create_item),
64+
Include("/extra", routes=[Path("/{user_id}/extra-info", create_item)]),
65+
],
66+
),
67+
Include("/account", app=child),
68+
],
69+
enable_openapi=True,
70+
)

docs_src/openapi/response_model_list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from lilya.contrib.openapi.decorator import openapi
33
from pydantic import BaseModel
44

5+
56
class Item(BaseModel):
67
id: str
78
name: str
@@ -10,8 +11,7 @@ class Item(BaseModel):
1011

1112
@openapi(
1213
responses={
13-
200: OpenAPIResponse(model=[Item], description="List of Person")
14+
200: OpenAPIResponse(model=[Item], description="List of Person"),
1415
}
1516
)
16-
async def list_people(request):
17-
...
17+
async def list_people(): ...

docs_src/openapi/single_level.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
from lilya.routing import Path, Include
33
from lilya.contrib.openapi.decorator import openapi
44

5+
56
@openapi(summary="Leaf endpoint")
6-
async def leaf_handler(request):
7+
async def leaf_handler():
78
return {"msg": "leaf"}
89

10+
911
app = Lilya(
1012
routes=[
1113
Include(
1214
"/nest",
1315
routes=[
14-
Path("/leaf", leaf_handler)
15-
]
16-
)
17-
]
16+
Path("/leaf", leaf_handler),
17+
],
18+
),
19+
],
1820
)

lilya/_internal/_templates/project_template/Taskfile.yaml.e-tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tasks:
1717
requirements:
1818
desc: Install requirements
1919
cmds:
20-
- pip install -r requirements/development.txt
20+
- pip install -e .[dev,test]
2121

2222
test:
2323
desc: Run the suite of tests
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[project]
2+
name = "{{ project_name }}"
3+
version = "0.1.0"
4+
description = "Project generated via Lilya version: {{ lilya_version }}"
5+
requires-python = ">=3.14"
6+
dependencies = [
7+
"lilya[standard]>={{ lilya_version }}",
8+
"gunicorn",
9+
"uvicorn"
10+
]
11+
12+
[project.optional-dependencies]
13+
dev = [
14+
"ruff>=0.15.0",
15+
]
16+
test = [
17+
"pytest",
18+
"pytest-cov",
19+
"pytest-asyncio",
20+
"anyio",
21+
"coverage",
22+
]
23+
24+
[tool.pytest.ini_options]
25+
testpaths = ["tests"]
26+
addopts = "-q"
27+
asyncio_mode = "auto"

lilya/_internal/_templates/project_template/requirements/base.txt.e-tpl

Lines changed: 0 additions & 3 deletions
This file was deleted.

lilya/_internal/_templates/project_template/requirements/development.txt.e-tpl

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)