Skip to content

Commit

Permalink
AddAllDomainPrimitivesSwaggerMappings caused an error if the asembly …
Browse files Browse the repository at this point in the history
…was referenced several times as the mapping was added multiple times
  • Loading branch information
Temo Nikolaishvili committed Apr 4, 2024
1 parent 8da9212 commit 0506cb0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>Domain Primitives</Product>
<Company>ALTA Software llc.</Company>
<Copyright>Copyright © 2024 ALTA Software llc.</Copyright>
<Version>2.2.1</Version>
<Version>2.2.3</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
5 changes: 4 additions & 1 deletion src/AltaSoft.DomainPrimitives/SwaggerGenOptionsExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ public static void AddAllDomainPrimitivesSwaggerMappings(this SwaggerGenOptions
.Where(a => IsSystemAssembly(a.FullName)).Select(a => a.FullName!));

var assembliesToCheck = new Queue<Assembly>(AppDomain.CurrentDomain.GetAssemblies());
var processedPrimitiveAssemblies = new HashSet<Assembly>();

while (assembliesToCheck.Count > 0)
{
var assembly = assembliesToCheck.Dequeue();

if (assembly.GetCustomAttribute<DomainPrimitiveAssemblyAttribute>() is not null)
if (!processedPrimitiveAssemblies.Contains(assembly) &&
assembly.GetCustomAttribute<DomainPrimitiveAssemblyAttribute>() is not null)
{
ProcessAssembly(assembly, options);
processedPrimitiveAssemblies.Add(assembly);
}

foreach (var reference in assembly.GetReferencedAssemblies())
Expand Down

0 comments on commit 0506cb0

Please sign in to comment.