Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Refitter.Core/RefitInterfaceImports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static string[] GetImportedNamespaces(RefitGeneratorSettings settings)
namespaces = namespaces.Except(excludedNamespaces).ToList();
}

if (settings.GenerateMultipleFiles && settings.ContractsNamespace is not null)
if (settings.ContractsNamespace is not null && settings.Namespace != settings.ContractsNamespace)
Comment thread
christianhelle marked this conversation as resolved.
{
namespaces.Add(settings.ContractsNamespace);
}
Expand Down
18 changes: 18 additions & 0 deletions src/Refitter.Tests/SwaggerPetstoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -848,4 +848,22 @@ public async Task Can_Generate_Interfaces_Filtered_By_Path_Match(SampleOpenSpeci
generateCode.Should().Contain("\"/pet\"");
generateCode.Should().Contain("\"/pet/{petId}\"");
}

[Theory]
[InlineData(SampleOpenSpecifications.SwaggerPetstoreJsonV3, "SwaggerPetstore.json")]
#if !DEBUG
[InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV3, "SwaggerPetstore.yaml")]
[InlineData(SampleOpenSpecifications.SwaggerPetstoreJsonV2, "SwaggerPetstore.json")]
[InlineData(SampleOpenSpecifications.SwaggerPetstoreYamlV2, "SwaggerPetstore.yaml")]
#endif
public async Task Can_Import_Contracts_Namespace(SampleOpenSpecifications version, string filename)
{
var settings = new RefitGeneratorSettings { ContractsNamespace = "Contracts" };
var generateCode = await GenerateCode(version, filename, settings);
generateCode.Should().Contain("using Contracts;");
BuildHelper
.BuildCSharp(generateCode)
.Should()
.BeTrue();
}
}
Loading