8

I. 我是使用 Django REST Swagger 编写 API 文档的新手。我试图了解如何编辑 a)“实施说明”和 b)参数描述。下图——

在此处输入图像描述

这是我对“崩溃”模型的看法。

class CrashViewSet(viewsets.ModelViewSet):
"""
retrieve: Get a single Crash instance

list: Get a list of all Crashes
"""
queryset = Crash.objects.all()
serializer_class = CrashSerializer
filter_backends = (SearchFilter,DjangoFilterBackend,OrderingFilter,)
search_fields = ('crash_id','crash_hr_short_desc','urb_area_short_nm','fc_short_desc',
                 'hwy_compnt_short_desc','mlge_typ_short_desc', 'specl_jrsdct_short_desc',
                 'jrsdct_grp_long_desc','st_full_nm','isect_st_full_nm','rd_char_short_desc',
                 'isect_typ_short_desc','crash_typ_short_desc','collis_typ_short_desc',
                 'rd_cntl_med_desc','wthr_cond_short_desc','rd_surf_short_desc','lgt_cond_short_desc',
                 'traf_cntl_device_short_desc','invstg_agy_short_desc','crash_cause_1_short_desc',
                 'crash_cause_2_short_desc','crash_cause_3_short_desc','pop_rng_med_desc','rd_cntl_med_desc')
filter_fields = ('ser_no','cnty_id','alchl_invlv_flg','crash_day_no','crash_mo_no','crash_yr_no','crash_hr_no',
                'schl_zone_ind','wrk_zone_ind','alchl_invlv_flg','drug_invlv_flg','crash_speed_invlv_flg',
                'crash_hit_run_flg',)
ordering_fields = '__all__'

我对 DocString 进行了一些编辑,但不太了解如何进行以便更全面地描述端点及其字段。我尝试阅读Django REST Swagger 教程,但没有给出关于如何格式化 DOCSTRING 的任何指示。最好的方法是什么?


二、另一个小问题是我想去掉“Django Login”按钮,因为这是公共 API。我该怎么做呢?在此处输入图像描述


三、API 文档有哪些最佳实践?

4

0 回答 0