Skip to content

Incorrect Import Statement for Resource Class in Generated Code with Swagger Codegen v3.0.46 #12516

Open
@yamireh

Description

@yamireh
Description

I have a swagger that has "Resource" on of it's swagger models.

When generating code using Swagger Codegen v3.0.46 and above, the generated ApiApi class includes the following incorrect import statement:

import org.springframework.core.io.Resource;

However, the application requires the import to point to a custom class which is part of my swagger:

import com.org.web.dto.Resource;

This issue occurs specifically for the Resource class, which conflicts with org.springframework.core.io.Resource due to naming overlap.

Swagger-codegen version

v3.0.46

Swagger declaration file content or url
Command line used for generation

JDK21
spring boot 3.4.1
io.swagger.codegen.v3
swagger-codegen-maven-plugin
3.0.46

Steps to reproduce

generate the swagger model classes and it won't compile due to importing the wrong Resource class.

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

      close