Skip to content

Commit 7b2bddf

Browse files
committed
testing automation
1 parent 929565a commit 7b2bddf

25 files changed

+143
-144
lines changed

.github/workflows/test_full.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ on:
77

88

99
jobs:
10-
test:
11-
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
15-
django-version: ['<2.1', '<2.2', '<3.0', '<3.1', '<3.2', '<3.3', '<4.1']
16-
17-
steps:
18-
- uses: actions/checkout@v2
19-
- name: Set up Python
20-
uses: actions/setup-python@v1
21-
with:
22-
python-version: ${{ matrix.python-version }}
23-
- name: Install core
24-
run: pip install "Django${{ matrix.django-version }}" pydantic
25-
- name: Install tests
26-
run: pip install pytest pytest-asyncio pytest-django injector==0.19.0 django-ninja asgiref contextlib2
27-
- name: Test
28-
run: pytest
10+
# test:
11+
# runs-on: ubuntu-latest
12+
# strategy:
13+
# matrix:
14+
# python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
15+
# django-version: ['<2.1', '<2.2', '<3.0', '<3.1', '<3.2', '<3.3', '<4.1']
16+
#
17+
# steps:
18+
# - uses: actions/checkout@v2
19+
# - name: Set up Python
20+
# uses: actions/setup-python@v1
21+
# with:
22+
# python-version: ${{ matrix.python-version }}
23+
# - name: Install core
24+
# run: pip install "Django${{ matrix.django-version }}" pydantic
25+
# - name: Install tests
26+
# run: pip install pytest pytest-asyncio pytest-django injector==0.19.0 django-ninja asgiref contextlib2
27+
# - name: Test
28+
# run: pytest
2929
codestyle:
3030
runs-on: ubuntu-latest
3131

@@ -46,4 +46,6 @@ jobs:
4646
- name: Flake8
4747
run: flake8 ninja_extra tests
4848
- name: mypy
49-
run: mypy ninja_extra
49+
run: mypy ninja_extra
50+
- name: Build and Deploy Document
51+
run: mkdocs build && mkdocs gh-deploy --force
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 121 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,121 @@
1-
![Test](https://github.com/eadwinCode/django-ninja-extra/workflows/Test/badge.svg)
2-
[![PyPI version](https://badge.fury.io/py/django-ninja-extra.svg)](https://badge.fury.io/py/django-ninja-extra)
3-
[![PyPI version](https://img.shields.io/pypi/v/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)
4-
[![PyPI version](https://img.shields.io/pypi/pyversions/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)
5-
[![PyPI version](https://img.shields.io/pypi/djversions/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)
6-
[![Codecov](https://img.shields.io/codecov/c/gh/eadwinCode/django-ninja-extra)](https://codecov.io/gh/eadwinCode/django-ninja-extra)
7-
[![Downloads](https://pepy.tech/badge/django-ninja-extra/month)](https://pepy.tech/project/django-ninja-extra)
8-
9-
# Django Ninja Extra
10-
11-
**Django Ninja Extra** is a complete class-based fashion of building and setting up APIs at incredible speed with incredible performance.
12-
It utilizes [**Django Ninja**](https://django-ninja.rest-framework.com) core features without compromising speed.
13-
14-
**Key features:**
15-
16-
All **Django-Ninja** features :
17-
18-
- **Easy**: Designed to be easy to use and intuitive.
19-
- **FAST execution**: Very high performance thanks to **<a href="https://pydantic-docs.helpmanual.io" target="_blank">Pydantic</a>** and **<a href="/async-support/">async support</a>**.
20-
- **Fast to code**: Type hints and automatic docs lets you focus only on business logic.
21-
- **Standards-based**: Based on the open standards for APIs: **OpenAPI** (previously known as Swagger) and **JSON Schema**.
22-
- **Django friendly**: (obviously) has good integration with the Django core and ORM.
23-
24-
Plus **Extra**:
25-
26-
- **Class Based**: Design your APIs in a class based fashion.
27-
- **Permissions**: Protect endpoint(s) at ease with defined permissions and authorizations at route level or controller level.
28-
- **Dependency Injection**: Controller classes supports dependency injection with python [**Injector** ](https://injector.readthedocs.io/en/latest/) or [**django_injector**](https://github.com/blubber/django_injector). Giving you the ability to inject API dependable services to APIController class and utilizing them where needed
29-
30-
---
31-
32-
### Requirements
33-
- Python >= 3.6
34-
- django >= 2.1
35-
- pydantic >= 1.6
36-
- Django-Ninja >= 0.16.1
37-
38-
## Django-Ninja Benchmark
39-
**Django-Ninja-Extra** uses **Django-Ninja** under the hood, it can be assumed that Django-Ninja-Extra has the same benchmark with Django-Ninja
40-
![Django Ninja REST Framework](images/benchmark.png)
41-
42-
Full documentation, [visit](https://eadwincode.github.io/django-ninja-extra/).
43-
44-
## Sample Project
45-
Django-Ninja-Tutorial Project, [visit](https://github.com/eadwinCode/bookstoreapi)
46-
47-
## Installation
48-
49-
```
50-
pip install django-ninja-extra
51-
```
52-
After installation, add `ninja_extra` to your `INSTALLED_APPS`
53-
54-
```Python
55-
INSTALLED_APPS = [
56-
...,
57-
'ninja_extra',
58-
]
59-
```
60-
61-
## Usage
62-
63-
In your django project next to urls.py create new `api.py` file:
64-
65-
```Python
66-
from ninja_extra import NinjaExtraAPI, api_controller, http_get
67-
68-
api = NinjaExtraAPI()
69-
70-
# function based definition
71-
@api.get("/add", tags=['Math'])
72-
def add(request, a: int, b: int):
73-
return {"result": a + b}
74-
75-
#class based definition
76-
@api_controller('/', tags=['Math'], permissions=[])
77-
class MathAPI:
78-
79-
@http_get('/subtract',)
80-
def subtract(self, a: int, b: int):
81-
"""Subtracts a from b"""
82-
return {"result": a - b}
83-
84-
@http_get('/divide',)
85-
def divide(self, a: int, b: int):
86-
"""Divides a by b"""
87-
return {"result": a / b}
88-
89-
@http_get('/multiple',)
90-
def multiple(self, a: int, b: int):
91-
"""Multiples a with b"""
92-
return {"result": a * b}
93-
94-
api.register_controllers(
95-
MathAPI
96-
)
97-
```
98-
99-
Now go to `urls.py` and add the following:
100-
101-
```Python
102-
...
103-
from django.urls import path
104-
from .api import api
105-
106-
urlpatterns = [
107-
path("admin/", admin.site.urls),
108-
path("api/", api.urls), # <---------- !
109-
]
110-
```
111-
112-
### Interactive API docs
113-
114-
Now go to <a href="http://127.0.0.1:8000/api/docs" target="_blank">http://127.0.0.1:8000/api/docs</a>
115-
116-
You will see the automatic interactive API documentation (provided by <a href="https://github.com/swagger-api/swagger-ui" target="_blank">Swagger UI</a>):
117-
118-
![Swagger UI](images/ui_swagger_preview_readme.gif)
119-
## What next?
120-
- To support this project, please give star it on Github
121-
- API Throttling
1+
![Test](https://github.com/eadwinCode/django-ninja-extra/workflows/Test/badge.svg)
2+
[![PyPI version](https://badge.fury.io/py/django-ninja-extra.svg)](https://badge.fury.io/py/django-ninja-extra)
3+
[![PyPI version](https://img.shields.io/pypi/v/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)
4+
[![PyPI version](https://img.shields.io/pypi/pyversions/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)
5+
[![PyPI version](https://img.shields.io/pypi/djversions/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)
6+
[![Codecov](https://img.shields.io/codecov/c/gh/eadwinCode/django-ninja-extra)](https://codecov.io/gh/eadwinCode/django-ninja-extra)
7+
[![Downloads](https://pepy.tech/badge/django-ninja-extra/month)](https://pepy.tech/project/django-ninja-extra)
8+
9+
# Django Ninja Extra
10+
11+
**Django Ninja Extra** is a complete class-based fashion of building and setting up APIs at incredible speed with incredible performance.
12+
It utilizes [**Django Ninja**](https://django-ninja.rest-framework.com) core features without compromising speed.
13+
14+
**Key features:**
15+
16+
All **Django-Ninja** features :
17+
18+
- **Easy**: Designed to be easy to use and intuitive.
19+
- **FAST execution**: Very high performance thanks to **<a href="https://pydantic-docs.helpmanual.io" target="_blank">Pydantic</a>** and **<a href="/async-support/">async support</a>**.
20+
- **Fast to code**: Type hints and automatic docs lets you focus only on business logic.
21+
- **Standards-based**: Based on the open standards for APIs: **OpenAPI** (previously known as Swagger) and **JSON Schema**.
22+
- **Django friendly**: (obviously) has good integration with the Django core and ORM.
23+
24+
Plus **Extra**:
25+
26+
- **Class Based**: Design your APIs in a class based fashion.
27+
- **Permissions**: Protect endpoint(s) at ease with defined permissions and authorizations at route level or controller level.
28+
- **Dependency Injection**: Controller classes supports dependency injection with python [**Injector** ](https://injector.readthedocs.io/en/latest/) or [**django_injector**](https://github.com/blubber/django_injector). Giving you the ability to inject API dependable services to APIController class and utilizing them where needed
29+
30+
---
31+
32+
### Requirements
33+
- Python >= 3.6
34+
- django >= 2.1
35+
- pydantic >= 1.6
36+
- Django-Ninja >= 0.16.1
37+
38+
## Django-Ninja Benchmark
39+
**Django-Ninja-Extra** uses **Django-Ninja** under the hood, it can be assumed that Django-Ninja-Extra has the same benchmark with Django-Ninja
40+
![Django Ninja REST Framework](images/benchmark.png)
41+
42+
Full documentation, [visit](https://eadwincode.github.io/django-ninja-extra/).
43+
44+
## Sample Project
45+
Django-Ninja-Tutorial Project, [visit](https://github.com/eadwinCode/bookstoreapi)
46+
47+
## Installation
48+
49+
```
50+
pip install django-ninja-extra
51+
```
52+
After installation, add `ninja_extra` to your `INSTALLED_APPS`
53+
54+
```Python
55+
INSTALLED_APPS = [
56+
...,
57+
'ninja_extra',
58+
]
59+
```
60+
61+
## Usage
62+
63+
In your django project next to urls.py create new `api.py` file:
64+
65+
```Python
66+
from ninja_extra import NinjaExtraAPI, api_controller, http_get
67+
68+
api = NinjaExtraAPI()
69+
70+
# function based definition
71+
@api.get("/add", tags=['Math'])
72+
def add(request, a: int, b: int):
73+
return {"result": a + b}
74+
75+
#class based definition
76+
@api_controller('/', tags=['Math'], permissions=[])
77+
class MathAPI:
78+
79+
@http_get('/subtract',)
80+
def subtract(self, a: int, b: int):
81+
"""Subtracts a from b"""
82+
return {"result": a - b}
83+
84+
@http_get('/divide',)
85+
def divide(self, a: int, b: int):
86+
"""Divides a by b"""
87+
return {"result": a / b}
88+
89+
@http_get('/multiple',)
90+
def multiple(self, a: int, b: int):
91+
"""Multiples a with b"""
92+
return {"result": a * b}
93+
94+
api.register_controllers(
95+
MathAPI
96+
)
97+
```
98+
99+
Now go to `urls.py` and add the following:
100+
101+
```Python
102+
...
103+
from django.urls import path
104+
from .api import api
105+
106+
urlpatterns = [
107+
path("admin/", admin.site.urls),
108+
path("api/", api.urls), # <---------- !
109+
]
110+
```
111+
112+
### Interactive API docs
113+
114+
Now go to <a href="http://127.0.0.1:8000/api/docs" target="_blank">http://127.0.0.1:8000/api/docs</a>
115+
116+
You will see the automatic interactive API documentation (provided by <a href="https://github.com/swagger-api/swagger-ui" target="_blank">Swagger UI</a>):
117+
118+
![Swagger UI](images/ui_swagger_preview_readme.gif)
119+
## What next?
120+
- To support this project, please give star it on Github
121+
- API Throttling

0 commit comments

Comments
 (0)