【发布时间】:2025-12-04 04:00:01
【问题描述】:
我们的 Django(Rest 框架)应用程序中有 url,例如:
r'^endpoint/(?P<item>[a-z_-]+)/$'
r'^endpoint/(?P<item>[a-z_-]+)/(?P<version>[0-9]+(\.[0-9])?)/$'
两者都有可用的 POST 方法。
一段时间以来,我们一直在使用 Swagger 来记录我们的 API,但想查看 Django Rest Framework 中包含的 coreapi 文档。
根据上述结构浏览我们的文档,coreapi 操作会导致:
# Initialize a client & load the schema document
client = coreapi.Client()
schema = client.get("http://localhost:8081/docs/")
# Interact with the first url
action = ["app", "endpoint > create"]
# Interact with the second url
action = ["app", "endpoint > create_0"]
我可以理解create_0 的来源,但理想情况下它会将关键字名称添加为后缀,例如create_version.
这可能吗?
【问题讨论】:
标签: django django-rest-framework core-api