[英]How to describe query parameters in DRF Docs?
I'm using Django REST Framework v3.9 built-in interactive documentation. 我正在使用Django REST Framework v3.9内置的交互式文档。
I have a url need query parameters for get. 我有一个url需要查询参数获取。 such as:
../jobs/?order_choice=0&city=1®ion=0
But i don't know how to documenting it in interactive documentation. 例如:
../jobs/?order_choice=0&city=1®ion=0
但我不知道如何在交互式文档中记录它。
I use method:
to add parameters: such as: 我使用
method:
添加参数:例如:
class JobListView(APIView):
"""
get:
- order_choices
- city
- region
- job_type
"""
but it print in one line 但它打印在一行
- order_choices - city - region - job_type
it's my parameters/ 这是我的参数/
params_data = {
'city': request.query_params.get('city', None),
'region': request.query_params.get('region', None),
'job_type': request.query_params.get('job_type', None),
'status': 1,
}
I want to know how to documenting it correctly. 我想知道如何正确记录它。
Try something like below ... 尝试类似下面的内容......
class PackageViewSet(viewsets.ModelViewSet):
"""
** Query Parameters **
`page` - get data of a particular page.
`page_size` - change total objects in a page (default=20).
** Filter Parameters **
`status` - `1/2`
** Search Parameters **
`name` - `search by package name`
** Ordering Parameters **
`name`
`created_at`
`updated_at`
** Default Ordering **
`-created_at`
`Method Allowed`
`GET -` `Lists all the Packages of a facility/company.`
`POST -` `Creates Package for a facility.`
`PUT -` `Updates a Package.`
`DELETE -` `deletes a Package.`
`POST/Create, PUT/Update`
{
"name": "package one",
"description": "package one",
"status": 1 // 1- Active, 2-Inactive
}
"""
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.