我正在处理自定义架构,Object of type Boolean is not JSON serializable
但在 Swagger 文档页面上出现错误提示。
import coreapi
import coreschema
from rest_framework.schemas import AutoSchema
class CustomSchema(AutoSchema):
def get_manual_fields(self, path, method):
manual_fields = []
if method == "POST":
manual_fields.extend(
[
coreapi.Field(
"custom_field",
required=False,
location="form",
description="custom field",
type=coreschema.Boolean()
)
]
)
return manual_fields
我注意到 usinglocation="query"
不会产生上述错误,但我在form
for Swagger 中需要它。有什么解决方法吗?提前致谢!