Releases: dymmond/esmerald
Releases · dymmond/esmerald
Version 3.6.0
Added
- New
Security
section with all the explanations how to use the internals of Esmerald. - Added new
Security
object used for security dependencies using Esmeraldesmerald.security
package.
Changed
- Updates from python-jose to PyJWT as dependency contrib library.
- Remove OpenAPI security as they where redundant and not 100% compliant with OpenAPI security.
- Allow the new Lilya StaticFiles allowing to provide multiple directories with fallthrough behaviour.
- Deprecate support for Mako.
- Internal code organisation and cleaning.
Fixed
- Fix cli detection of wrapped esmerald instances or different ASGI servers.
- Allow passing multiple
StaticFilesConfig
configurations in a tuple. - Allow passing multiple directories to
StaticFiles
by removing the stringification inStaticFilesConfig
so a fallthrough behavior can be established.
Note: this requires a newer lilya version.
Version 3.5.1
Changed
- Use assigned encoders at requests for json_encoder.
- Allow overwriting the
LILYA_ENCODER_TYPES
for different encoder sets or tests. - Use more orjson for encoding requests.
Version 3.5.0
Added
- Allow passing HTTP/WebSocket handlers directly to routes. They are automatically wrapped in Gateways-
- Allow passing HTTP/WebSocket handlers directly to routes as alternative to defining a Gateway/WebsocketGateway.
Changed
- Esmerald is now under the License BSD-3. This aims to protect the maintainers and contributors and
the license will be now the final. - Pluggables can now receive plain Extensions and Extension classes.
- Rename of Pluggables to Extensions:
- Breaking: The
pluggables
attribute and parameter are now renamed toextensions
. The old name is still available but deprecated. - Breaking: The
add_pluggable
method is now renamed toadd_extension
. The old name is still available but deprecated. - The documentation will refer now to extensions with
Pluggable
as a setup wrapper.
- Breaking: The
Fixed
- Directive
runserver
now allows the use of ASGI middlewares. - Remove the dependency of an app being an
esmerald
instance forrunserver
. - Check the environment variables instead of settings variable for esmerald settings in the runserver.
Version 3.4.4
Added
- Support for Taskfile when generating a project via directive.
- Add taskfile for development mode.
Changed
- Internal JSONResponse is now natively supporting ORJSON.
Version 3.4.3
Changed
- PydanticEncoder now tries mode
json
first as default. - Stop ignoring warnings in the tests.
- Stop shadowing the BaseDirective
help
from Lilya. - Asyncz settings for empty tasks.
- Update the docs for the templates.
Version 3.4.2
Changed
- OpenAPI for inheritance models using pydantic or any type of encoders.
- Stop supporting Python 3.8.
- Changed internal schema location in the helpers.
Version 3.4.1
3.4.1
Changed
- OpenAPI now if no
description
is provided from the handlers, it will read directly from
the docstrings. - Internal code cleaning and organisation.
Fixed
- OpenAPI query parameters were not rendering properly for optional
dict
orlist
types. This
was due to the internal evaluation of theNone
field which is now skipping for OpenAPI purposes.
Example
Now it is possible to do something like this:
from typing import Dict, List, Union, Optional
from esmerald import Gateway, JSONResponse, Query, get
@get("/item")
async def check_item(q: Union[List[str], None]) -> JSONResponse:
return JSONResponse({"value": q})
@get("/another-item")
async def check_item(q: Optional[Dict[str, str]]) -> JSONResponse:
return JSONResponse({"value": q})
Version 3.4.0
Added
- New ways of providing the request data allowing to pass a more complex body
using also the encoders. The complex body 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 and if you understand it.
Example
As per some examples of the documentation:
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:
{
"user": {
"name": "John",
"email": "john.doe@example.com",
},
"address": {
"street_name": "123 Queens Park",
"post_code": "90241"
}
}
More details can and must be read in the request data section.
Changed
- Overriding the
status_code
in any response is now possible directly by specifying the intended response and ignoring
the default from thehandler
.
Example
@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).
Version 3.3.7
Added
- New application generator using
--context
allowing to generate application scaffolds containing
more complex structures.
Changed
- jinja2 templating is now 100% delegated to its base, Lilya.
- Added examples in the documentation for windows users.
Fixed
- Lookup for summary in the handler for OpenAPI.
Version 3.3.6
Added
allow_private_networks
property toCORSMiddleware
.
Changed
Gateway
now allows to pass also an optionaloperation_id
as parameter for OpenAPI documentation allowing
multiple gateways to use the same handler and being recognised automatically by OpenAPI documentation.- OpenAPI documentation when multiple gateways use the same handler and no
operation_id
is declared,
automatically tries to generate a uniqueoperation_id
for it. - Internal code organisation for class based
View
to generate the routes in one place and reducing
code duplication. - Updated internal testing requirements for Edgy and Saffier and Lilya.