Commit Description
This commit is contained in:
@@ -25,7 +25,7 @@ Public Class BasicAuthenticationAttribute
|
||||
If isValid Then
|
||||
Dim principal = New GenericPrincipal(New GenericIdentity(userName), Nothing)
|
||||
Thread.CurrentPrincipal = principal
|
||||
actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.OK, "User " & userName & " successfully authenticated")
|
||||
'actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.OK, "User " & userName & " successfully authenticated")
|
||||
Return
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Imports System.Net.Http
|
||||
Imports System.IO
|
||||
Imports System.Net.Http
|
||||
Imports System.Reflection
|
||||
Imports System.Web.Http
|
||||
Imports System.Web.Http.Description
|
||||
Imports Microsoft.Extensions.Options
|
||||
@@ -19,9 +21,13 @@ Public Class SwaggerConfig
|
||||
Public Shared Sub Register(ByVal config As HttpConfiguration)
|
||||
Dim thisAssembly = GetType(SwaggerConfig).Assembly
|
||||
|
||||
Dim baseDirectory = AppDomain.CurrentDomain.BaseDirectory
|
||||
baseDirectory &= "\bin\"
|
||||
Dim commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML"
|
||||
Dim commentsFile = Path.Combine(baseDirectory, commentsFileName)
|
||||
|
||||
GlobalConfiguration.Configuration.EnableSwagger(Function(c)
|
||||
'c.SingleApiVersion("v1", descr)
|
||||
|
||||
|
||||
c.PrettyPrint()
|
||||
c.MultipleApiVersions(Function(apiDesc, targetApiVersion) ResolveVersionSupportByRouteConstraint(apiDesc, targetApiVersion), Function(vc)
|
||||
@@ -41,33 +47,29 @@ Public Class SwaggerConfig
|
||||
End Function)
|
||||
|
||||
|
||||
' c.OAuth2("oauth2").Description("OAuth2 Implicit Grant").Flow("implicit").AuthorizationUrl("http://petstore.swagger.wordnik.com/api/oauth/dialog").Scopes(Function(scopes)
|
||||
'End Function)
|
||||
c.BasicAuth("basic").Description("Basic HTTP Authentication")
|
||||
|
||||
c.IncludeXmlComments(commentsFile)
|
||||
|
||||
'c.ApiKey("apiKey").Description("API Key Authentication").Name("apiKey").In("header")
|
||||
|
||||
'c.RootUrl(Function(req) req.GetRouteData)
|
||||
|
||||
'c.OperationFilter(Of AddAuthorizationHeaderParameterOperationFilter)()
|
||||
|
||||
'c.OperationFilter(Of BasicAuthenticationAttribute)()
|
||||
|
||||
|
||||
'c.IncludeXmlComments($"{AppDomain.CurrentDomain.BaseDirectory}\bin\MyApi.XML")
|
||||
'c.RootUrl(Function(req) req.GetRouteData)
|
||||
|
||||
End Function).EnableSwaggerUi(Function(c)
|
||||
c.DocumentTitle(descr)
|
||||
|
||||
c.EnableDiscoveryUrlSelector()
|
||||
c.DocExpansion(DocExpansion.Full)
|
||||
'c.EnableApiKeySupport("apiKey", "header")
|
||||
'c.CustomAsset("index", yourAssembly, "YourWebApiProject.SwaggerExtensions.index.html")
|
||||
'c.EnableOAuth2Support(clientId:="test-client-id", clientSecret:=Nothing, realm:="test-realm", appName:="Swagger UI")
|
||||
'additionalQueryStringParams:=New Dictionary(Of String, String)() From {
|
||||
' {"foo", "bar"}
|
||||
'})
|
||||
c.DocExpansion(DocExpansion.List)
|
||||
|
||||
c.CustomAsset("index", thisAssembly, "VERAG_REST_SERVER.my_index.html")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End Function)
|
||||
|
||||
Reference in New Issue
Block a user