Skip to content

Commit a85534a

Browse files
authored
Merge pull request #41 from pmdevita/docs-1.4.0
Update docs and version for 1.4.0
2 parents 27fc4e8 + 0587ded commit a85534a

File tree

6 files changed

+104
-44
lines changed

6 files changed

+104
-44
lines changed

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
<a href="https://github.com/vitalik/django-ninja/issues/383"><img width="814" alt="SCR-20230123-m1t" src="https://user-images.githubusercontent.com/95222/214056666-585c0479-c122-4cb3-add4-b8844088ccdd.png"></a>
2-
3-
4-
5-
<a href="https://github.com/vitalik/django-ninja/issues/383">^ Please read (from the Shinobi's original author)^</a>
6-
7-
8-
9-
101
<p align="center">
112
<a href="https://pmdevita.github.io/django-shinobi/"><img src="https://pmdevita.github.io/django-shinobi/img/logo-big.png"></a>
123
</p>
@@ -28,8 +19,8 @@
2819
**Django Shinobi** is a web framework for building APIs with **Django** and Python 3.6+ **type hints**.
2920

3021
It's a fork of the fantastic **[Django Ninja](https://github.com/vitalik/django-ninja)** library focused on
31-
community-desired features and fixes. Read the [announcement](https://github.com/pmdevita/django-shinobi/discussions/5)
32-
for more info and check out the [roadmap](https://github.com/pmdevita/django-shinobi/discussions/6)!
22+
community-desired features and fixes. Check out the list of [differences](https://pmdevita.github.io/django-shinobi/differences/)
23+
if you're coming from Ninja, as well as the [roadmap](https://github.com/pmdevita/django-shinobi/discussions/6)!
3324

3425

3526
**Key features:**
@@ -51,16 +42,23 @@ for more info and check out the [roadmap](https://github.com/pmdevita/django-shi
5142

5243
## Installation
5344

45+
In your Django project, add Django Shinobi.
46+
5447
```
5548
pip install django-shinobi
5649
```
5750

51+
or start a new project.
5852

53+
```shell
54+
pip install django django-shinobi
55+
django-admin startproject apidemo
56+
```
5957

6058
## Usage
6159

6260

63-
In your django project next to urls.py create new `api.py` file:
61+
In your Django project, next to urls.py, create a new file called `api.py`.
6462

6563
```Python
6664
from ninja import NinjaAPI
@@ -98,6 +96,12 @@ Now you've just created an API that:
9896

9997
### Interactive API docs
10098

99+
Run your Django project
100+
101+
```shell
102+
python manage.py runsever
103+
```
104+
101105
Now go to <a href="http://127.0.0.1:8000/api/docs" target="_blank">http://127.0.0.1:8000/api/docs</a>
102106

103107
You will see the automatic interactive API documentation (provided by <a href="https://github.com/swagger-api/swagger-ui" target="_blank">Swagger UI</a> or <a href="https://github.com/Redocly/redoc" target="_blank">Redoc</a>):

docs/docs/differences.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ Shinobi has made a number of changes on top of Ninja. For those migrating from
44
Ninja to Shinobi, this guide exists to bring you up to speed on the fixes and
55
and new features.
66

7-
## Ninja 1.4.0 changes
7+
## Changes from Ninja
88

9-
At the time of writing, Shinobi includes development changes to Ninja that
10-
have not yet been released on Ninja. You can read the list of them them on the
11-
[1.4.0a release notes](https://github.com/pmdevita/django-shinobi/releases/tag/v1.4.0a).
12-
A write-up will be completed for them if Shinobi releases 1.4.0 before Ninja.
9+
Shinobi 1.4.0 is based on Ninja 1.4.3. You can read the changes for Ninja here.
10+
11+
- [Ninja 1.4.0](https://github.com/vitalik/django-ninja/releases/tag/v1.4.0)
12+
- [Ninja 1.4.1](https://github.com/vitalik/django-ninja/releases/tag/v1.4.1)
13+
- [Ninja 1.4.2](https://github.com/vitalik/django-ninja/releases/tag/v1.4.2)
14+
- [Ninja 1.4.3](https://github.com/vitalik/django-ninja/releases/tag/v1.4.3)
1315

1416
## Features
1517

@@ -138,3 +140,30 @@ Previously, while FileField and ImageField could show a non-null type, they woul
138140
null. This is fixed with the schema improvements and requires Pydantic 2.7.
139141
Fixing this created a regression where Pydantic 2.6 and older
140142
always show the field as nullable, so upgrading is recommended.
143+
144+
145+
## Build and CI Changes
146+
147+
### Better version compatibility
148+
149+
Shinobi now restricts versions of Pydantic to known tested and compatible ones. This should
150+
prevent surprise updates to Pydantic from breaking Shinobi.
151+
152+
### Improved CI testing
153+
154+
Previously, Ninja would only run tests against one specific version of Python, Django, and Pydantic.
155+
Consequentially, in order to hit 100% test coverage, many branches and lines had to be excluded from the
156+
coverage total, which also meant we didn't really have the full picture of line coverage.
157+
158+
Shinobi now tests against every supported combination of Python, Django, and Pydantic, and combines
159+
the coverage from them to account for version-specific code. If you're contributing to Shinobi and
160+
open a PR, you'll now also receive a comment detailing which tests passed and failed, and which lines
161+
are still missing in coverage.
162+
163+
These changes should make contributing easier and improve the awareness of our testing.
164+
165+
166+
## Support
167+
168+
To ease maintenance, Shinobi only supports [currently supported version of Django](https://www.djangoproject.com/download/#supported-versions).
169+
As of the release of 1.4.0, this includes Django 4.2, 5.1, and 5.2, along with their supported Python and Pydantic versions.

docs/docs/index.md

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Django Shinobi - Fast Django REST Framework
22

3-
<div style="background-color: black; color: red; font-size: 16px; padding: 8px;">
4-
RUSSIA INVADED UKRAINE - <a href="https://github.com/vitalik/django-ninja/issues/383">Please read (from Shinobi's original author)</a>
5-
</div>
6-
7-
83
![Django Shinobi](img/hero.png)
94

105
Django Shinobi is a web framework for building APIs with Django and Python 3.6+ type hints.
116

7+
It's a fork of the fantastic **[Django Ninja](https://github.com/vitalik/django-ninja)** library focused on
8+
community-desired features and fixes. Check out the list of [differences](https://pmdevita.github.io/django-shinobi/differences/)
9+
if you're coming from Ninja, as well as the [roadmap](https://github.com/pmdevita/django-shinobi/discussions/6)!
10+
11+
1212
Key features:
1313

1414
- **Easy**: Designed to be easy to use and intuitive.
@@ -24,57 +24,71 @@ Key features:
2424

2525
## Installation
2626

27+
In your Django project, add Django Shinobi.
28+
2729
```
2830
pip install django-shinobi
2931
```
3032

31-
## Quick Example
33+
or start a new project.
3234

33-
Start a new Django project (or use an existing one)
34-
```
35+
```shell
36+
pip install django django-shinobi
3537
django-admin startproject apidemo
3638
```
3739

38-
in `urls.py`
40+
## Usage
41+
42+
43+
In your Django project, next to urls.py, create a new file called `api.py`.
44+
3945

4046
```python hl_lines="3 5 8 9 10 15"
4147
{!./src/index001.py!}
4248
```
4349

44-
Now, run it as usual:
45-
```
46-
./manage.py runserver
47-
```
4850

49-
Note: You don't have to add Django Shinobi to your installed apps for it to work.
51+
Now go to `urls.py` and add the following:
5052

51-
## Check it
5253

53-
Open your browser at <a href="http://127.0.0.1:8000/api/add?a=1&b=2" target="_blank">http://127.0.0.1:8000/api/add?a=1&b=2</a>
54+
```Python hl_lines="3 7"
55+
...
56+
from .api import api
5457

55-
You will see the JSON response as:
56-
```JSON
57-
{"result": 3}
58+
urlpatterns = [
59+
path("admin/", admin.site.urls),
60+
path("api/", api.urls), # <---------- !
61+
]
5862
```
63+
64+
**That's it !**
65+
5966
Now you've just created an API that:
6067

6168
- receives an HTTP GET request at `/api/add`
6269
- takes, validates and type-casts GET parameters `a` and `b`
6370
- decodes the result to JSON
6471
- generates an OpenAPI schema for defined operation
6572

66-
## Interactive API docs
73+
### Interactive API docs
74+
75+
Run your Django project
76+
77+
```shell
78+
python manage.py runsever
79+
```
6780

6881
Now go to <a href="http://127.0.0.1:8000/api/docs" target="_blank">http://127.0.0.1:8000/api/docs</a>
6982

70-
You will see the automatic, interactive API documentation (provided by the <a href="https://github.com/swagger-api/swagger-ui" target="_blank">OpenAPI / Swagger UI</a> or <a href="https://github.com/Redocly/redoc" target="_blank">Redoc</a>):
83+
You will see the automatic interactive API documentation (provided by <a href="https://github.com/swagger-api/swagger-ui" target="_blank">Swagger UI</a> or <a href="https://github.com/Redocly/redoc" target="_blank">Redoc</a>):
84+
7185

72-
![Swagger UI](img/index-swagger-ui.png)
86+
![Swagger UI](docs/docs/img/index-swagger-ui.png)
7387

7488

7589
## Recap
7690

77-
In summary, you declare the types of parameters, body, etc. **once only**, as function parameters.
91+
In summary, you declare the types of parameters, body, etc. **once only**, as function parameters.
7892

7993
You do that with standard modern Python types.
8094

@@ -117,5 +131,9 @@ def operation(a: Item):
117131
* Files
118132
* Automatic, interactive API documentation
119133

120-
This project was heavily inspired by <a href="https://fastapi.tiangolo.com/" target="_blank">FastAPI</a> (developed by <a href="https://github.com/tiangolo" target="_blank">Sebastián Ramírez</a>)
134+
## What next?
121135

136+
- Read the full documentation here - https://pmdevita.github.io/django-shinobi
137+
- To support this project, please give star it on Github. ![github star](docs/docs/img/github-star.png)
138+
- Share it [via Twitter](https://twitter.com/intent/tweet?text=Check%20out%20Django%20Shinobi%20-%20Fast%20Django%20REST%20Framework%20-%20https%3A%2F%2Fpmdevita.github.io/django-shinobi)
139+
- Share your feedback and discuss development on Discord https://discord.gg/ntFTXu7NNv

docs/docs/tutorial/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ Start a new Django project (or if you already have an existing Django project, s
2323
django-admin startproject myproject
2424
```
2525

26+
If you're starting a new project, it's recommended to set `NINJA_COMPATIBILITY` to `False` to get the
27+
performance improvements.
28+
29+
```python
30+
# myproject/settings.py
31+
32+
NINJA_COMPATIBILITY = False
33+
```
34+
2635
## Create the API
2736

2837
Let's create a module for our API. Create an `api.py` file in the same directory location as your Django project's root `urls.py`:

docs/docs/tutorial/step3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Define a response Schema
44

5-
**Django Ninja** allows you to define the schema of your responses both for validation and documentation purposes.
5+
**Django Shinobi** allows you to define the schema of your responses both for validation and documentation purposes.
66

77
We'll create a third operation that will return information about the current Django user.
88

ninja/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
"""Django Ninja - Fast Django REST framework"""
1+
"""Django Shinobi - Fast Django REST framework"""
22

3-
__version__ = "1.4.3"
3+
__version__ = "1.4.0"
44

55

66
from pydantic import Field

0 commit comments

Comments
 (0)