Skip to content

Remove duplicated imports #1414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 11, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -1032,13 +1032,16 @@ private Map<String, Object> processOperations(CodegenConfig config, String tag,
}

List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
Set<String> mappingSet = new TreeSet<>();
for (String nextImport : allImports) {
Map<String, String> im = new LinkedHashMap<String, String>();
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/lua/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.2-SNAPSHOT
3.3.3-SNAPSHOT
1 change: 0 additions & 1 deletion samples/client/petstore/lua/petstore/api/pet_api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 0 additions & 1 deletion samples/client/petstore/lua/petstore/api/store_api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 0 additions & 1 deletion samples/client/petstore/lua/petstore/api/user_api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down