diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 0ad05b0762b..34a8534c6cd 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -430,6 +430,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { } operations.put("imports", imports); + + // add a flag to indicate whether there's any {{import}} + if (imports.size() > 0) { + operations.put("hasImport", true); + } + config.postProcessOperations(operations); if (objs.size() > 0) { List os = (List) objs.get("operation"); diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache index 3ede1c783a1..47fcc1bef1d 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache @@ -4,13 +4,11 @@ using System.Collections.Generic; using System.Threading.Tasks; using RestSharp; using {{packageName}}.Client; -using {{packageName}}.Model; -{{#imports}} -{{/imports}} +{{#hasImport}}using {{packageName}}.Model; +{{/hasImport}} namespace {{packageName}}.Api { {{#operations}} - public interface I{{classname}} { {{#operation}} /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs index 96f6f93af57..ab213f94f5a 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs @@ -8,7 +8,6 @@ using IO.Swagger.Model; namespace IO.Swagger.Api { - public interface IPetApi { /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs index 90ec2487d9d..ad9e296721c 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs @@ -8,7 +8,6 @@ using IO.Swagger.Model; namespace IO.Swagger.Api { - public interface IStoreApi { /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs index 0e3ed36c595..92b35a640e6 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs @@ -8,7 +8,6 @@ using IO.Swagger.Model; namespace IO.Swagger.Api { - public interface IUserApi { ///