安裝 Swagger
刪除 SwaggerConfig.cs 新增 SwaggerConfig.vb
增加底下程式碼 :
Imports System.Web.Http Imports VBwebAPI Imports Swashbuckle.Application <Assembly: PreApplicationStartMethod(GetType(SwaggerConfig), "Register")> Public Class SwaggerConfig Public Shared Sub Register() Dim thisAssembly = GetType(SwaggerConfig).Assembly GlobalConfiguration.Configuration.EnableSwagger(Function(c) c.SingleApiVersion("v1", "Yourwebapiname")).EnableSwaggerUi() End Sub End Class
遇到 Model 名稱重複的問題,故修改成 :
Public Shared Sub Register() Dim thisAssembly = GetType(SwaggerConfig).Assembly GlobalConfiguration.Configuration.EnableSwagger( Function(c) c.SingleApiVersion("v1", "Yourwebapiname") c.SchemaId(Function(x) x.FullName) End Function).EnableSwaggerUi() End Sub
參考
https://forums.asp.net/t/2136956.aspx?Swagger+for+webapi+on+Visual+basic+or+alternative+