Jaad
Overview
Jaad is an addition to Django.
It is based on Django Rest Framework and is designed to simplify the syntax needed to expose a resilient REST API.
Installation
To install Jaad using pip run:
pip install jaad
Creating a new project
To create a new project create a project directory
and use jaad-admin.py startproject.
This will create the following files:
.
|-- server/
| |-- apps/
| | |-- __init__.py
| | `-- index/
| | |-- __init__.py
| | |-- parameters.py
| | `-- view.py
| |-- logs/
| |-- settings/
| | |-- __init__.py
| | |-- application.py
| | |-- local.py
| | `-- __init__.py
| `-- urls.py
`-- manage.py
manage.py is the classic Django management script hence
you can run your server using:
DJANGO_SETTINGS_MODULE=server.settings.local python manage.py runserver
This will launch your server and make it available here: http://127.0.0.1:8000/
A default Index view was automatically created.
You can have a look at its definition in server/apps/index/
as it uses Jaad core features.
Creating a new view
To create a view create a submodule in apps and define in it a class inheriting from JaadView. Then define the HTTP method you want to support:
from jaad.view import JaadView
class Hello(JaadView):
def get(self, request):
return "Hello"
def post(self, request):
return "This was a POST request"
You can then expose it by modifying server/urls.py
Defining parameters
You can define a set of parameters that a view support using a Jaad Form:
from jaad.forms import fields
class HelloWorldParameters(fields.Form):
name = fields.StringField(
required=True,
help_text="Enter your name :)"
)
And then using it in your views:
from jaad.view import JaadView, with_parameters
class Hello(JaadView):
@with_parameters("GET", HelloWorldParameters)
def get(self, request, parameters):
return "Hello {}".format(parameters["name"])
def post(self, request):
return "This was a POST request"
The additional parameter used to call your method contains your parameter values validated and converted to python objects (int, datetime, ...).
with_parameters can be called with as many Form as you want and will add a parameter to your method for each Form.
Interactive documentation
You can add an interactive documentation to your API using
jaad-admin.py add-doc.
This will create the following files in server/apps/
documentation/
|-- static/
| `-- css/
| `-- documentation.css
|-- templates/
| `-- rest_framework_swagger/
| |-- base.html
| `-- index.html
`-- urls.py
This is a Swagger UI that relies on Django Rest Framework Swagger and is not exposed yet.
To expose it:
- In
server/urls.pyimportincludefromdjango.conf.urlsif not already done and addurl(r'^doc/', include('documentation.urls'))to urlpatterns. - Add
'server.apps.documentation'toINSTALLED_APPSinserver/settings/application.py
You can now access your API documentation on http://127.0.0.1:8000/doc/
The documentation is automatically updated based on all exposed view docstrings and parameter definitions.
Metadata
Release files for jaad 0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| jaad-0.11.tar.gz | 25.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jaad-0.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.9 kB
Release files / jaad-0.11.tar.gz
| Download URL | jaad-0.11.tar.gz |
|---|---|
| Size | 25.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03a871657bd7e3dfd57da14745b04c796be0b75f5fcf70269a6f47fca3f0190b
|
|
BLAKE2b-256 checksum How to use checksums |
a411ee8d1a86f283d4e84295f274c6d4b704e5557c732cdf9b53e999014588a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Release files / jaad-0.11-py3-none-any.whl
| Download URL | jaad-0.11-py3-none-any.whl |
|---|---|
| Size | 29.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3cdd525bdb0238210994667dec4d5f259f41ae2f4fbd20ae2d8d97faa0e4008e
|
|
BLAKE2b-256 checksum How to use checksums |
66afd8a0feaa37fad347469e7740642bf6a436883f41c9e643ceede4271e1888
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Security for jaad 0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.