drf-yasg-examples
Add example value on your swagger documentation!
Requirements
Python 3.6.1 or higher
drf-yasg based code base
Install
With pip
pip install drf-yasg-examples
With Poetry
poetry add drf-yasg-examples
Configuration
Edit your django config file.
SWAGGER_SETTINGS = {
'DEFAULT_AUTO_SCHEMA_CLASS': 'drf_yasg_examples.SwaggerAutoSchema',
}
Note: If you use SwaggerAutoSchema class other codes, replace them together
Usage
ChoiceField
Just write verbose text like this in your models.
class Product(models.Model):
CATEGORY = [
('F', 'Food'),
('L', 'Living Item'),
]
category = models.CharField(
verbose_name='Category',
max_length=1,
choices=CATEGORY,
)
And ModelSerializer might set this field as ChoiceField, and this package write down enum k-v list on your documentation automatically.
Others
Write example value in your serializer class like this.
class ProductSerializer(serializers.ModelSerializer):
class Meta:
model = Product
fields = '__all__'
example = {
'name': 'Apple',
'amount': 6,
'price': '10.00',
}
Then drf-yasg will add example on your docs automatically.
LICENSE
MIT
Metadata
Release files for drf-yasg-examples 0.1.1
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 | Actions |
|---|---|---|---|---|
| drf-yasg-examples-0.1.1.tar.gz | 3.2 kB | Without provenance | Details for drf-yasg-examples-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drf_yasg_examples-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for drf_yasg_examples-0.1.1-py3-none-any.whl |
Total release size: 6.4 kB
Release files / drf-yasg-examples-0.1.1.tar.gz
| Download URL | drf-yasg-examples-0.1.1.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de91a1070b4c1f3b90eec8a75e188fed0bc464f1bdbfb64718ee3ce92b9c543a
|
|
BLAKE2b-256 checksum How to use checksums |
3c0519131d3e9b3772214a9fb8f841db967f5ac321350f487ee9608768b132ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.8.2 Darwin/19.3.0
|
Release files / drf_yasg_examples-0.1.1-py3-none-any.whl
| Download URL | drf_yasg_examples-0.1.1-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1d6a28cd0b36777417ba10c12e9f7bf90d84ca1a36e434bf127e8c37730b2ba
|
|
BLAKE2b-256 checksum How to use checksums |
1dece65673178d25a35a4d8a980378061305fae91171fcd30fd61154e0c71955
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.8.2 Darwin/19.3.0
|
Security for drf-yasg-examples 0.1.1
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.