-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,91 @@ hide: | |
|
||
# Release Notes | ||
|
||
## 3.4.0 | ||
|
||
### Added | ||
|
||
- New ways of providing the [request data](./extras/request-data.md) allowing to pass a more complex body | ||
using also the [encoders](./encoders.md). The [complex body](./extras/request-data.md#complex-request-data) is explained | ||
and how to achieve this result. | ||
|
||
!!! Warning | ||
This is an **additional** functionality to the existing one and it does not represent any replacement. Be sure | ||
you read the [documentation](./extras/request-data.md) and if you understand it. | ||
|
||
#### Example | ||
|
||
As per some examples of the documentation: | ||
|
||
```python | ||
from pydantic import BaseModel, EmailStr | ||
|
||
from esmerald import Esmerald, Gateway, post | ||
|
||
|
||
class User(BaseModel): | ||
name: str | ||
email: EmailStr | ||
|
||
|
||
class Address(BaseModel): | ||
street_name: str | ||
post_code: str | ||
|
||
|
||
@post("/create") | ||
async def create_user(user: User, address: Address) -> None: | ||
""" | ||
Creates a user in the system and does not return anything. | ||
Default status_code: 201 | ||
""" | ||
|
||
|
||
app = Esmerald(routes=[Gateway(handler=create_user)]) | ||
``` | ||
|
||
You can expect to send a payload like this: | ||
|
||
```json | ||
{ | ||
"user": { | ||
"name": "John", | ||
"email": "[email protected]", | ||
}, | ||
"address": { | ||
"street_name": "123 Queens Park", | ||
"post_code": "90241" | ||
} | ||
} | ||
``` | ||
|
||
More details can and must be read in the [request data](./extras/request-data.md) section. | ||
|
||
### Changed | ||
|
||
- Overriding the `status_code` in any response is now possible directly by specifying the intended response and ignoring | ||
the default from the `handler`. | ||
|
||
#### Example | ||
|
||
```python | ||
@get() | ||
def create(name: Union[str, None]) -> Response: | ||
if name is None: | ||
return Response("Ok") | ||
if name == "something": | ||
return Response("Ok", status_code=status.HTTP_401_UNAUTHORIZED) | ||
if name == "something-else": | ||
return Response("Ok", status_code=status.HTTP_300_MULTIPLE_CHOICES) | ||
``` | ||
|
||
If none of the conditions are met, then it will always default to the `status_code` of the handler which in the `get` case, | ||
its `200`. | ||
|
||
### Fixed | ||
|
||
- Internal parsing of the encoders for OpenAPI representation and removed unused code *(deprecated)*. | ||
|
||
## 3.3.7 | ||
|
||
### Added | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "3.3.7" | ||
__version__ = "3.4.0" | ||
|
||
|
||
from lilya import status | ||
|