使用 Swagger UI 设置 Api 版本 [英] Setting the Api Version with Swagger UI

查看:43
本文介绍了使用 Swagger UI 设置 Api 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过使用 Jersey 开发的 REST API,我们通过 swagger-ui 记录了 REST API.不幸的是,我们并没有从第一天开始对 API 进行版本控制.我们现在正在尝试向 API 添加版本控制.

I have a REST API developed through the use of Jersey and we document the REST API through swagger-ui. Unfortunately, we did not start versioning the API from day 1. We are now trying to add versioning to the API.

我采取的第一步是尝试更新由动态生成的 swagger (html) 页面显示的 API 版本.我一直跟踪调用流程到 sw​​agger-ui.js 文件,但我无法弄清楚如何更改动态生成页面底部显示的 API 版本.

The first step I'm taking is I'm trying to update the API version that is displayed by the dynamically generated swagger (html) page. I've traced the call flow all the way to the swagger-ui.js file but I can't figure out how to change the displayed API version at the bottom of the dynamically generated page.

当前显示在底部的默认值为API VERSION: 1.0.0".

The default that is currently displayed at the bottom is ' API VERSION: 1.0.0 '.

我在这里阅读了一些关于ServiceStack的内容,但不幸的是我正在处理的代码库没有使用任何类型的东西.

I've read something about a ServiceStack here but unfortunately the code base I'm working on doesn't use anything of the sort.

有人可以指点我需要更改/更新的位置/内容以更新显示的 API 版本号吗?

Could anyone please kindly point me to where/what I would need to change/update in order to update the displayed API version number?

推荐答案

您可以添加 Bootstrap servlet 来设置 Swagger 配置 bean 的参数,如下所述 -

You can add a Bootstrap servlet to set parameters for the Swagger config bean as described here -

https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5

这篇关于使用 Swagger UI 设置 Api 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆