Skip to content

Commit

Permalink
Merge pull request #83 from heXelium/#82
Browse files Browse the repository at this point in the history
Added support for marking interfaces with SwaggerWcf attribute #82
  • Loading branch information
abelsilva authored Jul 22, 2017
2 parents 03c216d + 076fd92 commit 6e29fb7
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/SwaggerWcf/Support/Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal Mapper(IList<string> hiddenTags, List<string> visibleTags)
internal readonly IEnumerable<string> HiddenTags;
internal readonly IEnumerable<string> VisibleTags;

internal IEnumerable<Path> FindMethods(string basePath, Type serviceType, IList<Type> definitionsTypesList)
internal IEnumerable<Path> FindMethods(string basePath, Type markedType, IList<Type> definitionsTypesList)
{
bool addedSlash = false;
List<Path> paths = new List<Path>();
Expand All @@ -37,9 +37,30 @@ internal IEnumerable<Path> FindMethods(string basePath, Type serviceType, IList<
basePath = basePath + "/";
}

//search all interfaces for this type for potential DataContracts, and build a set of items
List<Type> types = serviceType.GetInterfaces().ToList();
types.Add(serviceType);
List<Type> types;
Type serviceType;
if (markedType.IsInterface)
{
//search for service impl type
var allTypes = AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(type => markedType.IsAssignableFrom(type) && !type.IsInterface)
.ToList();

serviceType = allTypes.Except(allTypes.Select(type => type.BaseType)).Single();

types = new List<Type> {markedType};
}
else
{
serviceType = markedType;

//search all interfaces for this type for potential DataContracts, and build a set of items
types = serviceType.GetInterfaces().ToList();
types.Add(serviceType);
}

foreach (Type i in types)
{
Attribute dc = i.GetCustomAttribute(typeof(ServiceContractAttribute));
Expand Down

0 comments on commit 6e29fb7

Please sign in to comment.