Skip to content

[JAVA] generating Map with jaxrs-reasteasy-eap does not import the hashmap #8168

@matteocodogno

Description

@matteocodogno
Description

Generating Map with jaxrs-reasteasy-eap does not import the hashmap, the generated code contains the map initialization: private Map<String, String> testMap = new HashMap<String, String>(); but not the HashMap import.

package io.swagger.model;

import java.util.Objects;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.*;
import io.swagger.annotations.*;

@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaResteasyEapServerCodegen", date = "2018-05-09T17:52:15.629Z")
public class AlignmentData   {
  
  private Map<String, String> testMap = new HashMap<String, String>();

  ...

}

This issue causes a compilation error.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project adapter: Compilation failure
[ERROR] /project-path/target/generated-sources/swagger/src/gen/java/main/io/swagger/model/AlignmentData.java:[16,45] cannot find symbol
[ERROR] symbol:   class HashMap
Swagger-codegen version

2.3.1

Swagger declaration file content or url

swagger declaration file

Command line used for generation

The java code was generated both by online swagger editor and swagger-codegen-maven-plugin

Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions