2
votes

I have two models Package and File. Both are JPA entities that are annotated with @ApiModel. Also there is a ManyToMany relationship between them.

There are other classes that reference Package and File though.

I already added a value to the @ApiModel annotation.

@ApiModel(value = "the package")
public class Package {

   @ManyToMany(cascade = {
        CascadeType.PERSIST,
        CascadeType.MERGE
    })
    @JoinTable(
        name = "file_package",
        joinColumns = @JoinColumn(name = "file_id"),
        inverseJoinColumns = @JoinColumn(name = "package_id")
    )
    @ApiModelProperty(name = "The list of files")
    private List<File> files = new ArrayList<>();

}

In the swagger ui (localhost:8080/swagger-ui.html#/), the Package model appears 3 times as:

Package Package_1 Package_2 Package_3

The weird part is that if I create a REST controller that uses Package or File I get this error:

java.lang.IllegalStateException: Ambiguous models equality when conditions is empty. at springfox.documentation.spring.web.scanners.ApiModelReader.checkCondition(ApiModelReader.java:655) at springfox.documentation.spring.web.scanners.ApiModelReader.mergeConditions(ApiModelReader.java:537) at springfox.documentation.spring.web.scanners.ApiModelReader.mergeModelBranch(ApiModelReader.java:236) at springfox.documentation.spring.web.scanners.ApiModelReader.read(ApiModelReader.java:149) at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:144)

1
Are you using version 3.0.0.SNAPSHOT by any chance? See github.com/springfox/springfox/issues/2345 - Risav Karna

1 Answers

0
votes

Still, an open issue

Related to spring data-rest. Hope for fix in next release.

https://github.com/springfox/springfox/issues/3014?_pjax=%23js-repo-pjax-container