我们使用Swashbuckle在.NET API(不是Core)上设置了Swagger。
我正在寻找LucyBot,以使文档页面看起来更好。查看他们的样本,他们的OpenAPI文件在根目录处有一个“标签”元素,该元素用于将显示内容分成几组。我们的(/ swagger / docs / v1)没有这样的元素。我尝试过在SwaggerConfig.cs中看到的所有内容,但是没有运气。
有什么简单的方法可以自动生成此信息?一些选择,评论或我只是忽略的东西?
"swagger": "2.0",
"info": {
"description": "This is a demo of [LucyBot's API Documentation](http:\/\/lucybot.com) using swagger.io's Petstore server. You can find out more about Swagger at [http:\/\/swagger.io](http:\/\/swagger.io) or on [irc.freenode.net, #swagger](http:\/\/swagger.io\/irc\/). For this sample, you can use the api key `special-key` to test the authorization filters.\n\nTo use this documentation for your own API, visit [http:\/\/lucybot.com](http:\/\/lucybot.com)",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http:\/\/swagger.io\/terms\/",
"contact": {
"email": "apiteam@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http:\/\/www.apache.org\/licenses\/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.io",
"basePath": "\/v2",
"tags": [
{
"name": "pet",
"description": "Everything about your Pets",
"externalDocs": {
"description": "Find out more",
"url": "http:\/\/swagger.io"
}
},
{
"name": "store",
"description": "Access to Petstore orders"
},
{
"name": "user",
"description": "Operations about user",
"externalDocs": {
"description": "Find out more about our store",
"url": "http:\/\/swagger.io"
}
}
],```
答案 0 :(得分:0)
查看externalDocs的代码swashbuckle代码:
https://github.com/domaindrivendev/Swashbuckle/blob/master/Swashbuckle.Core/Swagger/SwaggerDocument.cs#L134
定义中有很好的东西,但是没有在任何地方使用...
我认为您唯一的选择是使用IDocumentFilter并注入缺少的标签。
这是如何使用这些过滤器的示例:
https://github.com/domaindrivendev/Swashbuckle/blob/5489aca0d2dd7946f5569341f621f581720d4634/Swashbuckle.Dummy.Core/SwaggerExtensions/AppendVersionToBasePath.cs