Skip to content

SpringCodegen not importing java.util.Map #7432

Open
@mhdubose

Description

@mhdubose
Description

When using the codegen maven plugin and the Spring language, java.util.Map is not being imported when the Map's value is a List.

Swagger-codegen version

Maven plugin version 2.3.1

Swagger declaration file content or url
paths:
  /customer:
    get:
      tags:
        - Customers
      summary: Retrieve all customers
      produces:
        - application/json
      responses:
        '200':
          description: OK
          schema:
            type: object
            additionalProperties:
              type: array
              items:
                type: string

the output of this is correct

default ResponseEntity<Map<String, List<String>>>

but the class does not have java.util.Map imported, and therefore fails to build

target/generated-sources/swagger/src/gen/java/main/io/swagger/api/CustomerApi.java:[54,28] cannot find symbol
  symbol:   class Map
  location: interface io.swagger.api.CustomerApi

Maven configuration
<plugin>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.3.1</version>
                <executions>
                    <execution>
                        <id>generate-server</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>swagger.yaml</inputSpec>
                            <language>spring</language>
                            <configOptions>
                                <sourceFolder>src/gen/java/main</sourceFolder>
                                <delegatePattern>true</delegatePattern>
                                <java8>true</java8>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

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