ServiceStack Swagger UI and API version number

2019-06-26 14:52发布

Is there anyway to get the version number into the swagger UI?

So we can let developers know what version each deployment is at?

2条回答
Anthone
2楼-- · 2019-06-26 15:15

If you are looking to display the version for the API as a whole, there is support for this in Swagger UI as noted here. Additionally, this support made it into ServiceStack and will display properly on the bottom of the screen the same as the Swagger example.

Unfortunately, there isn't yet support for accessing the ApiVersion property in your code as seen here. This property isn't exposed in version 3 or 4 of ServiceStack or even in the new Model and Property filters on the Swagger feature. Accessing this would require a pull request to expose it.

查看更多
来,给爷笑一个
3楼-- · 2019-06-26 15:27

This is possible in the latest version of ServiceStack, you just set the ServiceStack API version in your AppHost thus :

public override void Configure(Container container)
{
     SetConfig(new HostConfig
     {
         ApiVersion = "1.1"
     });
{

This will then be picked up by the Swagger-Ui

查看更多
登录 后发表回答