Django-ninja

Latest version: v1.3.0

Safety actively analyzes 688053 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 7

0.17.0

This release brings few long awaited features:

Smarter schema

Now you can access orm instance attributes inside schema with **resolvers**:
Python
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:

Python
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:

Python
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
* AkeemMcLennon
* stefanitsky
* mom1

**Full Changelog**: https://github.com/vitalik/django-ninja/compare/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:
- daviddavis
- shamaevnn
- SmileyChris
- antonrh
- s3lcuk
- idahogray
- TaeHyoungKwon
- dekoza

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](https://django-ninja.rest-framework.com/tutorial/django-pydantic/) - 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](https://django-ninja.rest-framework.com/tutorial/path-params/#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](https://django-ninja.rest-framework.com/tutorial/pagination/) - 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 )

Page 4 of 7

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.