Skip to content

Commit

Permalink
Adds possibility to set an optional basepath in the Configure method.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias.olofsson committed Feb 4, 2018
1 parent 4af5deb commit f6c49bd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/SwaggerWcf/SwaggerWcfEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ internal SwaggerWcfEndpoint(Func<string, Service> buildService)

internal static SecurityDefinitions SecurityDefinitions { get; private set; }

internal static string BasePath { get; private set; }

private static Dictionary<string, string> SwaggerFiles { get; } = new Dictionary<string, string>();

public static bool DisableSwaggerUI { get; set; }
Expand All @@ -42,10 +44,11 @@ internal SwaggerWcfEndpoint(Func<string, Service> buildService)
public static Func<string, List<string>, List<string>> FilterHiddenTags { get; set; } =
(string path, List<string> hiddenTags) => hiddenTags;

public static void Configure(Info info, SecurityDefinitions securityDefinitions = null)
public static void Configure(Info info, SecurityDefinitions securityDefinitions = null, string basePath = null)
{
Info = info;
SecurityDefinitions = securityDefinitions;
BasePath = basePath;
}

[MethodImpl(MethodImplOptions.Synchronized)]
Expand All @@ -60,6 +63,8 @@ internal static void Init(Func<string, Service> buildService)
service.Info = Info;
if (SecurityDefinitions != null)
service.SecurityDefinitions = SecurityDefinitions;
if (BasePath != null)
service.BasePath = BasePath;

string swagger = Serializer.Process(service);
if (SwaggerFiles.ContainsKey(path) == false)
Expand Down Expand Up @@ -130,7 +135,9 @@ public Stream StaticContent(string content)
? content.Substring(0, content.IndexOf("?", StringComparison.Ordinal))
: content;

Stream stream = Support.StaticContent.GetFile(filename, out string contentType, out long contentLength);
string contentType;
long contentLength;
Stream stream = Support.StaticContent.GetFile(filename, out contentType, out contentLength);

if (stream == Stream.Null)
{
Expand Down

0 comments on commit f6c49bd

Please sign in to comment.