diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index a18fffa3582..e21b7cf3bab 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -1032,13 +1032,16 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { } List> imports = new ArrayList>(); + Set mappingSet = new TreeSet<>(); for (String nextImport : allImports) { Map im = new LinkedHashMap(); String mapping = config.importMapping().get(nextImport); if (mapping == null) { mapping = config.toModelImport(nextImport); } - if (mapping != null) { + + if (mapping != null && !mappingSet.contains(mapping)) { // ensure import (mapping) is unique + mappingSet.add(mapping); im.put("import", mapping); im.put("classname", nextImport); if (!imports.contains(im)) { // avoid duplicates diff --git a/modules/openapi-generator/src/main/resources/Java/JSON.mustache b/modules/openapi-generator/src/main/resources/Java/JSON.mustache index e207efbc05b..b7f458c9d12 100644 --- a/modules/openapi-generator/src/main/resources/Java/JSON.mustache +++ b/modules/openapi-generator/src/main/resources/Java/JSON.mustache @@ -25,9 +25,9 @@ import org.threeten.bp.OffsetDateTime; import org.threeten.bp.format.DateTimeFormatter; {{/threetenbp}} -{{#parent.length}} +{{#models.0}} import {{modelPackage}}.*; -{{/parent.length}} +{{/models.0}} import okio.ByteString; import java.io.IOException; diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/JSON.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/JSON.mustache index a7e1df8598a..9ba7567bffe 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/JSON.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/JSON.mustache @@ -25,9 +25,9 @@ import org.threeten.bp.OffsetDateTime; import org.threeten.bp.format.DateTimeFormatter; {{/threetenbp}} -{{#parent.length}} +{{#models.0}} import {{modelPackage}}.*; -{{/parent.length}} +{{/models.0}} import java.io.IOException; import java.io.StringReader; diff --git a/samples/client/petstore/lua/.openapi-generator/VERSION b/samples/client/petstore/lua/.openapi-generator/VERSION index a6527129083..e24c1f857e0 100644 --- a/samples/client/petstore/lua/.openapi-generator/VERSION +++ b/samples/client/petstore/lua/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.2-SNAPSHOT \ No newline at end of file +3.3.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/lua/petstore/api/pet_api.lua b/samples/client/petstore/lua/petstore/api/pet_api.lua index 9e27ac3bdb1..eb5657ce697 100644 --- a/samples/client/petstore/lua/petstore/api/pet_api.lua +++ b/samples/client/petstore/lua/petstore/api/pet_api.lua @@ -18,7 +18,6 @@ local basexx = require "basexx" -- model import local petstore_api_response = require "petstore.model.api_response" local petstore_pet = require "petstore.model.pet" -local petstore_pet = require "petstore.model.pet" local pet_api = {} local pet_api_mt = { diff --git a/samples/client/petstore/lua/petstore/api/store_api.lua b/samples/client/petstore/lua/petstore/api/store_api.lua index 0ef6ae56bc7..e3432cac5f9 100644 --- a/samples/client/petstore/lua/petstore/api/store_api.lua +++ b/samples/client/petstore/lua/petstore/api/store_api.lua @@ -17,7 +17,6 @@ local basexx = require "basexx" -- model import local petstore_order = require "petstore.model.order" -local petstore_order = require "petstore.model.order" local store_api = {} local store_api_mt = { diff --git a/samples/client/petstore/lua/petstore/api/user_api.lua b/samples/client/petstore/lua/petstore/api/user_api.lua index 1febe3aee48..3008016cf89 100644 --- a/samples/client/petstore/lua/petstore/api/user_api.lua +++ b/samples/client/petstore/lua/petstore/api/user_api.lua @@ -17,7 +17,6 @@ local basexx = require "basexx" -- model import local petstore_user = require "petstore.model.user" -local petstore_user = require "petstore.model.user" local user_api = {} local user_api_mt = {