Python 在Django@schema(自动模式)中设置对象(手动字段=
我正在使用django rest api,该api接收端点中的对象 有些对象属性是必需的,有些则不是 我想在文档中显示这一点,但我不知道如何使用手动字段显示对象 现在我只有对象的名称,如:Python 在Django@schema(自动模式)中设置对象(手动字段=,python,django,django-rest-framework,django-views,Python,Django,Django Rest Framework,Django Views,我正在使用django rest api,该api接收端点中的对象 有些对象属性是必需的,有些则不是 我想在文档中显示这一点,但我不知道如何使用手动字段显示对象 现在我只有对象的名称,如: @schema(AutoSchema(manual_fields=[ coreapi.Field("node", required=True, location="query", description="Node Object") ])) 文档中显示了这一点,如下所
@schema(AutoSchema(manual_fields=[
coreapi.Field("node", required=True, location="query", description="Node Object")
]))
文档中显示了这一点,如下所示:
使用coreschema设置描述
from rest_framework.compat import coreschema
coreapi.Field(
name=name, required=required, location=location,
schema=coreschema.String(title=name, description=description)
)
使用coreschema设置描述
from rest_framework.compat import coreschema
coreapi.Field(
name=name, required=required, location=location,
schema=coreschema.String(title=name, description=description)
)