github pmdevita/django-shinobi v1.4.0
1.4.0

11 days ago

Shinobi 1.4.0 is based on Ninja 1.4.3. You can read the changes for Ninja here.

You can find more info about the differences with Ninja in the docs.

Highlights

Schema performance improvements

It's taken a lot of work over the past few months but the performance improvements for Schema are now complete! When enabled, you should see a significant speed up in Schema validation. One particularly heavy response that was tested saw a 15x improvement in speed.

Before (~512ms):

image

After (~34ms):

image

Using the benchmarks from https://github.com/oscarychen/building-efficient-api, it looks like Shinobi scores about 20% faster in median time. Shinobi is still almost twice as slow as FastAPI, so there remains much more to do in optimization.

image

Choices support

ModelSchema now supports including a Field's choices in validation and the OpenAPI spec. You can also use TextChoices or
IntegerChoices to declare reusable Enum Schema, helpful for auto-generated API clients.

Auto-generated aliases now work with ForeignKey Fields

Previously, if you were using auto-generated aliases (to convert to camelCase, for example), any ForeignKey Fields you might
pull in with ModelSchema did not have their names aliased correctly. This is now fixed.

Primary keys and blanks are now opt-in nullable

Ninja 1.3.0 silently introduced a breaking change where any primary key or blank Model Fields would get marked as nullable by ModelSchema. This change broke the data contract you might make through your OpenAPI schema, as a primary key should never be null, and blank is a setting used for form validation. This has been reverted to the previous behavior.

I have little information about how this change affects users. If this breaks your use case, feel free to open an issue on Shinobi.

More robust testing and version support

Ninja's CI testing only checked coverage against one specific version of Python, Django, and Pydantic, meaning our visibility into how well Ninja supported your particular combination of installs was limited. This also meant version specific code had to be excluded from coverage, turning PR merging into a game of whack-a-mole.

Shinobi now checks all currently supported versions of Django, and their compatible Python and Pydantic versions, and
combines the coverage from them. From here, we can start removing coverage exclusions and find more blind spots in the tests.

Full Changelog

These are the full changes, including those released in 1.4.0a.

Features

  • Improve performance by removing DjangoGetter by @pmdevita in #28
  • ModelSchema: Add support for choices by @pmdevita in #23

Bug Fixes

  • Use property to alias ForeignKey fields instead of Pydantic alias by @pmdevita in #7
  • Fix tests on Pydantic 2.11 and sync Ruff version by @pmdevita in #11
  • Fix primary key always being marked as nullable in schema by @pmdevita in #8

Docs

  • Docs: Update dependencies, fix building by @pmdevita in #4
  • Docs: Update contact links, more renames, link fixes by @pmdevita in #18
  • Docs: Add Ninja migration guide by @pmdevita in #24
  • Update docs and version for 1.4.0 by @pmdevita in #41

Build/CI

  • CI: Set full_test runner to use Ubuntu 22 for Python 3.7 by @pmdevita in #10
  • Build docs CI by @pmdevita in #13
  • Increment version to 1.4.0a, use trusted publisher by @pmdevita in #14
  • Combine coverage from all test runs by @pmdevita in #34
  • Update support to only currently supported versions of Django and Python by @pmdevita in #37
  • Merge Ninja 1.4.3 by @pmdevita in #40

Full Changelog: v1.4.0a...v1.4.0

Don't miss a new django-shinobi release

NewReleases is sending notifications on new releases.