drf-schema-adapter


Namedrf-schema-adapter JSON
Version 3.0.6 PyPI version JSON
download
home_pagehttps://github.com/drf-forms/drf-schema-adapter
SummaryMaking using Django with frontend libraries and frameworks DRYer
upload_time2023-03-10 10:16:08
maintainer
docs_urlNone
authorEmmanuelle Delescolle, Adrien Brunet, Mauro Bianchi, Mattia Larentis, Aaron Elliot Ross
requires_python
licenseMIT License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # DRF-schema-adapter ![Build Status](https://github.com/drf-forms/drf-schema-adapter/actions/workflows/test.yml/badge.svg?branch=master)

`drf-schema-adapter` is a set of tools used to make it as straight-forward to declare an API endpoint
as it is to declare a new `ModelAdmin` in Django and export the corresponding definition to frontend
frameworks and libraries.

## Compatibility Matrix

**DRF-schema-adapter** is compatible with the following matrix

|                 | Py 3.8       | Py 3.9       | Py 3.10      | Py 3.11      |
| --------------- | ------------ | ------------ | ------------ | ------------ |
| **Django 3.2**  | DRF 3.12+    | DRF 3.12+    | N/A          | N/A          |
| **Django 4.0**  | DRF 3.12+    | DRF 3.12+    | DRF 3.12+    | N/A          |
| **Django 4.1**  | DRF 3.12+    | DRF 3.12+    | DRF 3.12+    | DRF 3.12+    |

:warning: For Python 2.7 or Django 1.x support, please use versions 1.x or prior
:warning: For Django Version 3.1 or prior, use version 2.x

:warning: For Python 3.11 compatibility, you will have (for now) to install Inflector directly from the repo:
```bash
pip install git+https://github.com/ixmatus/inflector@ef5c19dc2aa8df5e6b4c452ff2d9b54ec41a04a8#egg=Inflector
```

## Installation

### With pip

```bash
pip install drf-schema-adapter
```

If you are using python 3.11, you will have to also install Inflector directly from the repo, pending the release of Inflector 3.0.2

```bash
pip install git+https://github.com/ixmatus/inflector@ef5c19dc2aa8df5e6b4c452ff2d9b54ec41a04a8#egg=Inflector
```

### From source

Within the source directory:

```bash
python setup.py install
```


## Demo application

You can see a demo application running at
[https://djembersample.pythonanywhere.com/](https://djembersample.pythonanywhere.com/).

## Basic usage

First of all you'll need to import the default EndpointRouter in your urls.py file.

```python
from drf_auto_endpoint.router import router
```

As well as add its urls to your `urlpatterns` in `urls.py`, the same way you would with DRF's
`DefaultRouter`.

```python
urlpatterns = [
    ...
    path("api/", include(router.urls)),
    ...
]
```

### Prototyping

The quickest way to get a working endpoint is to register a model with the router. Register accepts
an optional keyword argument for the `url` associated to that endpoint. By default the url for an
endpoint willbe `app_label/verbose_name_plural`

```python
from django.urls import include, path
from drf_auto_endpoint.router import router
from my_app.models import MyModel, OtherModel

router.register(MyModel)
router.register(OtherModel, url='my_custom_url')

urlpatterns = [
    path("api/", include(router.urls)),
]
```

### Adding schema information to your `OPTIONS` calls

Django REST framework provides the ability to customize those calls thanks to
[metadata classes](http://www.django-rest-framework.org/api-guide/metadata/).

Setup DRF to use one of **DRF-schema-adapter**'s metadata classes to get schema information:

```python
## settings.py

...
REST_FRAMEWORK = {
    'DEFAULT_METADATA_CLASS': 'drf_auto_endpoint.metadata.AutoMetadata',
}
```


### Exporting to the frontend

First add `'export_app'` to your setting's `INSTALLED_APPS`, then run:

```bash
./manage.py export --adapter_name EmberAdapter samples/products
```

## Full documentation

For much more complete documentation, please see: http://drf-schema-adapter.readthedocs.io

## Related projects

- Django:
  - [Django Rest Framework](http://www.django-rest-framework.org/)
  - [DRF-Base64](https://bitbucket.org/levit_scs/drf_base64)
- Ember:
  - [ember-cli-dynamic-model](https://bitbucket.org/levit_scs/ember-cli-dynamic-model)
  - [ember-cli-crudities](https://bitbucket.org/levit_scs/ember-cli-crudities)
- Angular:
  - [angular-formly](http://angular-formly.com/)
- React:
  _nothing so far_
- Third-party adapters:
  _nothing so far_

## Contibuting guide-lines

If you'd like to contibute to *DRF-schema-adapter**, you are more than welcome to do so. In order to
make contributing to this project a rich experience for everyone, please follow these guide-lines:

- First, fork the project with your own GitHub account, build your code on your own repository and
submit a pull-request once your contribution is ready.
- Before contributing a bug-fix or new feature, create an issue explaining what the problem/need is
first. When submitting your pull-request, make sure to reference the original issue.
- For any code you contribute, make sure to follow PEP8 recommendation (soft line-limit 100, hard
limit 120).
- For bug-fixes, please first write a test that will fail with the current code and passes using your
patch. For easier evaluation, please do so in 2 separate commits
- For new features, if your feature can be implemented as a third-party app (like new adapters), please
don't contribute them to this repo, publish your own application and open an issue telling us about it.
We will make sure to add a link to your application in this README.
- Read and respect the [Code Of Conduct](./COC.md)

## ToDo

- [ ] Write better documentation
- [ ] Write more/better tests

---

License information available [here](LICENSE.md).

Contributors code of conduct is available [here](COC.md). Note that this COC **will** be enforced.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/drf-forms/drf-schema-adapter",
    "name": "drf-schema-adapter",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Emmanuelle Delescolle, Adrien Brunet, Mauro Bianchi, Mattia Larentis, Aaron Elliot Ross",
    "author_email": "info@levit.be",
    "download_url": "https://files.pythonhosted.org/packages/ed/56/9a12a2b2428279873c8704b3475deed2bad7fed5f0e050652feca531a512/drf-schema-adapter-3.0.6.tar.gz",
    "platform": null,
    "description": "# DRF-schema-adapter ![Build Status](https://github.com/drf-forms/drf-schema-adapter/actions/workflows/test.yml/badge.svg?branch=master)\n\n`drf-schema-adapter` is a set of tools used to make it as straight-forward to declare an API endpoint\nas it is to declare a new `ModelAdmin` in Django and export the corresponding definition to frontend\nframeworks and libraries.\n\n## Compatibility Matrix\n\n**DRF-schema-adapter** is compatible with the following matrix\n\n|                 | Py 3.8       | Py 3.9       | Py 3.10      | Py 3.11      |\n| --------------- | ------------ | ------------ | ------------ | ------------ |\n| **Django 3.2**  | DRF 3.12+    | DRF 3.12+    | N/A          | N/A          |\n| **Django 4.0**  | DRF 3.12+    | DRF 3.12+    | DRF 3.12+    | N/A          |\n| **Django 4.1**  | DRF 3.12+    | DRF 3.12+    | DRF 3.12+    | DRF 3.12+    |\n\n:warning: For Python 2.7 or Django 1.x support, please use versions 1.x or prior\n:warning: For Django Version 3.1 or prior, use version 2.x\n\n:warning: For Python 3.11 compatibility, you will have (for now) to install Inflector directly from the repo:\n```bash\npip install git+https://github.com/ixmatus/inflector@ef5c19dc2aa8df5e6b4c452ff2d9b54ec41a04a8#egg=Inflector\n```\n\n## Installation\n\n### With pip\n\n```bash\npip install drf-schema-adapter\n```\n\nIf you are using python 3.11, you will have to also install Inflector directly from the repo, pending the release of Inflector 3.0.2\n\n```bash\npip install git+https://github.com/ixmatus/inflector@ef5c19dc2aa8df5e6b4c452ff2d9b54ec41a04a8#egg=Inflector\n```\n\n### From source\n\nWithin the source directory:\n\n```bash\npython setup.py install\n```\n\n\n## Demo application\n\nYou can see a demo application running at\n[https://djembersample.pythonanywhere.com/](https://djembersample.pythonanywhere.com/).\n\n## Basic usage\n\nFirst of all you'll need to import the default EndpointRouter in your urls.py file.\n\n```python\nfrom drf_auto_endpoint.router import router\n```\n\nAs well as add its urls to your `urlpatterns` in `urls.py`, the same way you would with DRF's\n`DefaultRouter`.\n\n```python\nurlpatterns = [\n    ...\n    path(\"api/\", include(router.urls)),\n    ...\n]\n```\n\n### Prototyping\n\nThe quickest way to get a working endpoint is to register a model with the router. Register accepts\nan optional keyword argument for the `url` associated to that endpoint. By default the url for an\nendpoint willbe `app_label/verbose_name_plural`\n\n```python\nfrom django.urls import include, path\nfrom drf_auto_endpoint.router import router\nfrom my_app.models import MyModel, OtherModel\n\nrouter.register(MyModel)\nrouter.register(OtherModel, url='my_custom_url')\n\nurlpatterns = [\n    path(\"api/\", include(router.urls)),\n]\n```\n\n### Adding schema information to your `OPTIONS` calls\n\nDjango REST framework provides the ability to customize those calls thanks to\n[metadata classes](http://www.django-rest-framework.org/api-guide/metadata/).\n\nSetup DRF to use one of **DRF-schema-adapter**'s metadata classes to get schema information:\n\n```python\n## settings.py\n\n...\nREST_FRAMEWORK = {\n    'DEFAULT_METADATA_CLASS': 'drf_auto_endpoint.metadata.AutoMetadata',\n}\n```\n\n\n### Exporting to the frontend\n\nFirst add `'export_app'` to your setting's `INSTALLED_APPS`, then run:\n\n```bash\n./manage.py export --adapter_name EmberAdapter samples/products\n```\n\n## Full documentation\n\nFor much more complete documentation, please see: http://drf-schema-adapter.readthedocs.io\n\n## Related projects\n\n- Django:\n  - [Django Rest Framework](http://www.django-rest-framework.org/)\n  - [DRF-Base64](https://bitbucket.org/levit_scs/drf_base64)\n- Ember:\n  - [ember-cli-dynamic-model](https://bitbucket.org/levit_scs/ember-cli-dynamic-model)\n  - [ember-cli-crudities](https://bitbucket.org/levit_scs/ember-cli-crudities)\n- Angular:\n  - [angular-formly](http://angular-formly.com/)\n- React:\n  _nothing so far_\n- Third-party adapters:\n  _nothing so far_\n\n## Contibuting guide-lines\n\nIf you'd like to contibute to *DRF-schema-adapter**, you are more than welcome to do so. In order to\nmake contributing to this project a rich experience for everyone, please follow these guide-lines:\n\n- First, fork the project with your own GitHub account, build your code on your own repository and\nsubmit a pull-request once your contribution is ready.\n- Before contributing a bug-fix or new feature, create an issue explaining what the problem/need is\nfirst. When submitting your pull-request, make sure to reference the original issue.\n- For any code you contribute, make sure to follow PEP8 recommendation (soft line-limit 100, hard\nlimit 120).\n- For bug-fixes, please first write a test that will fail with the current code and passes using your\npatch. For easier evaluation, please do so in 2 separate commits\n- For new features, if your feature can be implemented as a third-party app (like new adapters), please\ndon't contribute them to this repo, publish your own application and open an issue telling us about it.\nWe will make sure to add a link to your application in this README.\n- Read and respect the [Code Of Conduct](./COC.md)\n\n## ToDo\n\n- [ ] Write better documentation\n- [ ] Write more/better tests\n\n---\n\nLicense information available [here](LICENSE.md).\n\nContributors code of conduct is available [here](COC.md). Note that this COC **will** be enforced.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Making using Django with frontend libraries and frameworks DRYer",
    "version": "3.0.6",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ed569a12a2b2428279873c8704b3475deed2bad7fed5f0e050652feca531a512",
                "md5": "7639348f0b5da316b1b03d49f56308ec",
                "sha256": "6c02c77136da234b3b5c3ae2b5db0bff5c19b3298b513f02d38966bf617a6cf3"
            },
            "downloads": -1,
            "filename": "drf-schema-adapter-3.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "7639348f0b5da316b1b03d49f56308ec",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 34173,
            "upload_time": "2023-03-10T10:16:08",
            "upload_time_iso_8601": "2023-03-10T10:16:08.041791Z",
            "url": "https://files.pythonhosted.org/packages/ed/56/9a12a2b2428279873c8704b3475deed2bad7fed5f0e050652feca531a512/drf-schema-adapter-3.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-10 10:16:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "drf-forms",
    "github_project": "drf-schema-adapter",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "drf-schema-adapter"
}
        
Elapsed time: 0.05421s