Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating doc for entities with map attribute does not work #1634

Closed
tonithomsson opened this issue Apr 26, 2022 · 0 comments
Closed

Generating doc for entities with map attribute does not work #1634

tonithomsson opened this issue Apr 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@tonithomsson
Copy link

Generating doc for entities with map attribute does not work

  1. Create a SpringBoot project with jdk17 at
    https://start.spring.io/#!type=gradle-project&language=java&platformVersion=2.6.7&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=data-rest,data-mongodb,web

  2. Add dependencies:
    implementation 'org.springdoc:springdoc-openapi-ui:1.6.8'
    implementation 'org.springdoc:springdoc-openapi-data-rest:1.6.8'

  3. Create a interface and model:
    @RepositoryRestResource
    public interface PersonRepository extends MongoRepository<Person, String> {
    }

public class Person {
@id
public String id;
public String name;

@DocumentReference
public Map<String, Person> friends = new HashMap<>();

}

  1. Start app and open http://localhost:8080/swagger-ui/index.html
    causes the following error:
    2022-04-26 22:31:23.236 ERROR 93367 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Mismatched number of generics specified for private static class org.springdoc.data.rest.core.DataRestResponseService$MapModel] with root cause

java.lang.IllegalArgumentException: Mismatched number of generics specified for private static class org.springdoc.data.rest.core.DataRestResponseService$MapModel
at org.springframework.util.Assert.isTrue(Assert.java:139) ~[spring-core-5.3.19.jar:5.3.19]
at org.springframework.core.ResolvableType.forClassWithGenerics(ResolvableType.java:1088) ~[spring-core-5.3.19.jar:5.3.19]
at org.springframework.core.ResolvableType.forClassWithGenerics(ResolvableType.java:1074) ~[spring-core-5.3.19.jar:5.3.19]
at org.springdoc.data.rest.core.DataRestResponseService.resolveGenericType(DataRestResponseService.java:361) ~[springdoc-openapi-data-rest-1.6.8.jar:1.6.8]

@bnasslahsen bnasslahsen added the bug Something isn't working label May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants