Skip to content

[JavaSpring] Import conflict with generated model and one of the libraries of same name  #14867

@agharshu17

Description

@agharshu17

I have a schema named 'ResponseEntity'. The model class gets generated with the same name.
This conflicts with the ResponseEntiy class of Springframework and gives an error

error: a type with the same simple name is already defined by the single-type-import of ResponseEntity
import org.springframework.http.ResponseEntity;

API File:
default ResponseEntity myClass() {
// code
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}

Here, the func return-type ResponseEntity is from org.springframework.http.ResponseEntity
whereas the Generic type(one in the <>) ResponseEntity is my model class.

Discarded approaches:

  1. I do not want to use importmappings to create an external model and map it to the ResponseEntity model. This will create issues on changing the swagger schema.
  2. I cannot add Suffix/Prefix to all the generated models.

Is there a way such that?

  1. I can add Suffix/Prefix to only that particular generated model.
  2. Any workaround to never let the class 'org.springframework.http.ResponseEntity' be imported. I will add this in the ResponseEntity method of api.mustache class as a prefix.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions