如何使用版本控制Django OpenAPI文档

发布于 2025-02-13 18:00:26 字数 464 浏览 2 评论 0原文

我试图开发我的第一个django rentful api。
我已经实施了一些功能,并且已经进入了路由,视图,连续化器等。
现在,我想设置一些我当前已实施的所有内容的文档。因此,我已经设置了drf_yasg Swagger文档,并将路由添加到Swagger.json和Swagger-UI。

但是

现在最重要的是:我需要 API版本。 我已经实现了两条路线(V1和V2),路由很好。
但是Swagger网站上的文档显示两个版本。那很丑陋。我现在正在努力几个小时,以找到一个解决方案,以找到如何在不同页面上显示其版本,但实际上没有关于这种行为的文档。

谁能帮忙?

我来自.NET世界,在那里我可以用 apiontioning 自动实施

Swagger解决方案。

Im trying to develop my first Django RESTFul API.
I have implemented some functionality and already got into Routing, Views, Serializers and so on.
Now i would like to setup some Documentation of everything i have currently implemented. So I have set up drf_yasg Swagger Documentation and added routes to the swagger.json and the swagger-ui.

BUT

The most important thing now: I need Api Versioning.
I have implemented two routes (v1 and v2) and the routing is fine.
But the documentation on the swagger site displays BOTH versions. and thats very very ugly. Im now struggeling for hours to find a solution how swagger finds its versions to display on diffrent pages but theres really not documentation about this behavior.

Can anyone help out?

I come from .NET world and there I can implement Swagger with ApiVersioning and Swagger automatically make a dropdown into the ui for me where i can choose, which documentation i w ant to read

Thanks and I hope we can find a solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文