Releases: vitalik/django-ninja
0.18.0
Hello
Please welcome the new Django Ninja version
it has lot of fixes and improvements
Most notable a HttpResponse typed argument by @SmileyChris
Now you can manage response behaviour (cookies, headers, streaming) flixible:
@api.post("/boop")
def boop(request, response: HttpResponse): # !
response.set_cookie("beep", "boop") # !
return True
All changes
- Provide a temporal HttpResponse typed argument to views by @SmileyChris in #336
- UploadedFile inherit from Django's UploadedFile by @OtherBarry in #400
- Allow path parameters to be specified at router level by @kaschnit in #369
- Added support for postgress specific fields to Model Schema #353
- Fixed openapi/pydantic versions compatibility #418
- pre-commit config by @SmileyChris in #364
- Access to test response attributes by @stephane in #402
- Small optimization and typing improvements by @SmileyChris in #367
- Minor typo in tutorial by @stephane in #387
- Specify mypy in CONTRIBUTING.md by @OtherBarry in #401
- ConfigError: ModelSchema classes requires a 'Config' subclass by @sebastian-philipp in #382
- Fix a typing issue by @HoJin9622 in #404
- Fix a few typos by @dy3l in #426
- Add Redoc support by @kxxoling in #427
- Fix typo in docs by @sho918 in #432
- Handle class instances in
signature.details.is_collection_type
by @flaeppe in #434 - Upgrade versions of pre-commit hooks by @flaeppe in #435
New Contributors
- @kaschnit made their first contribution in #369
- @stephane made their first contribution in #387
- @OtherBarry made their first contribution in #400
- @sebastian-philipp made their first contribution in #382
- @HoJin9622 made their first contribution in #404
- @dy3l made their first contribution in #426
- @kxxoling made their first contribution in #427
- @sho918 made their first contribution in #432
- @flaeppe made their first contribution in #434
Full Changelog: v0.17.0...v0.18.0
0.17.0
This release brings few long awaited features:
Smarter schema
Now you can access orm instance attributes inside schema with resolvers:
class TaskSchema(Schema):
title: str
is_completed: bool
owner: Optional[str]
lower_title: str
@staticmethod
def resolve_owner(obj): # <------- !!!!!!
if not obj.owner:
return
return f"{obj.owner.first_name} {obj.owner.last_name}"
def resolve_lower_title(self, obj): # <-------- !!!!!!
return self.title.lower()
Field aliases now support django template variables dotted syntax:
class TaskSchema(Schema):
...
last_comment: str = Field(..., alias="comment_set.0.text")
Thanks to @SmileyChris
Pagination output
Now default paginated output returns a dict with items
and count
You can now override both input and output schemas for custom pagination:
class CustomPagination(PaginationBase):
class Input(Schema):
page: int
class Output(Schema):
items: List[Any]
total_pages: int
current_page: int
def paginate_queryset(self, queryset, pagination: Input, **params):
return {
'items': ...,
'total_pages': ...,
'current_page': ...,
}
All updates:
- Improved pagination by @vitalik
- Smarter schema that handles dotted aliases and resolver methods by @SmileyChris #317
- Add support for union type in payload by @AkeemMcLennon #301
- Export OpenAPI schema management cmd by @stefanitsky #288
- First key derivation optimization by @mom1 #344
**kwargs
not required anymore for pagination by @mom1 #285
New Contributors
Full Changelog: v0.16.2...v0.17.0
0.16.2
- Pydantic 1.9.0 support #310 by @antonrh
- Fix params descriptions visualization in swagger ui #331 by @ldbenitez
- Improve TestClient json argument-serialization #315 by @johnbergvall
- Add python 3.10 to test matrix #273 by @jairhenrique
- Automate github actions update. #274 by @jairhenrique
Many documentaion fixes and improvements by:
0.16.1
- Resolve #229 & #240 reporting dev errors under django dev-server (#242 by @stephenrauch)
- Allow NOT_SET to survive copy.deepcopy() (#241 by @stephenrauch)
0.16.0
OpenAPI schemas names
Generating OpenAPI automatically created schema names changed for duplicated names (see #230)
Now instead of silence (or exceptions on other cases) django-ninja will just add sequential number suffix to the schema name in OpenAPI spec.
For example if you already have schema called "User" and in some other module you create another "User" schema - the second will have name "User2" in openapi json.
Other
- Dot in query regression #238 (#239 by @stephenrauch)
- Fix openapi schema title and description propagation for query, cookie, header, etc #123 (#233 from @stephenrauch)
- Fix form schema single param #236 (#237 from @stephenrauch)
- Improve #181, query with list type (#234 by @stephenrauch)
- Path signature check (#232 by @stephenrauch)
- Document how to handle empty form fields (#228 by @stephenrauch)
- Misc fixes (#231 by @ehdgua01)
0.15.0
Major changes
- Introduced ModelSchema - declarative way to create schemas from django models
- Allow arbitrary mix of params Body, Form & File w/ multipart. (#226 by @stephenrauch) (also fixes #134, #162, #201)
- Path params now support Django path converters (#187 by @stephenrauch)
Other changes
- Fixed #208 - Missing schema in requestBody (#209 by @stephenrauch)
- UploadedFile usability #120
- Types for "urls" property #155
- Optimize tests (#217 by @mawassk)
- Better error message for duplicate orm schema names #214 (#215 @stephenrauch)
- Test coverage for branches (#211 @stephenrauch)
- Formatting & styling for test files (#218 by @stephenrauch)
- Documentation improvements (#207 by @eadwinCode, #205 #206 by @johnthagen )
0.14.0
Hello Everyone,
This is a very nice release, which includes some new functionality and fixes
And more important there are lot of people contributed to this update
Thank you
- Added experimental Pagination support - allows you easely paginate your querysets and customize pages (note - this feature currently in beta and may change a bit in future udpates)
- Added support for streaming responses (#149 by @ErwinJunge )
- Mixing simple arguments and models arguments in GET parameters (#178 by @stephenrauch )
- Handle custom exceptions in authentication (#174 by @dozer133 )
- Added build_absolute_uri on test client (#168 by @jairhenrique )
- Typing improvements (#167, #170 by @davidszotten )
- Fix assertion message (#175 by @igoose1 )
- Resolve #148, missing wraps(), with a better error message. (#184 by @stephenrauch)
- Improved documentation on forward refs ( #161 by @stephenrauch )
- Fixed add_router() to router already attached to API ( #188 by @stephenrauch )
- Bumped Swagger UI to 3.51.2 ( #192 by @igoose1 )
0.13.2
0.13.1
0.13.0
- Fixed
create_schema
ValueError
on pydantic 1.8.2 (#135) - Allow collection fields to be identified when an alias is used #133 (by @kierandarcy )
- New argument
custom_fields
increate_schema
to override or add fields - Fixed create_schema Json field (#127)
- Include ninja TestClient into distributed package