Cannot generate api-doc when @RestController implements any interface - springdoc-openapi-ui

Viewed 282

Info about my project:

  • Open Java 11.01
  • springdoc-openapi-ui 1.5.2
  • Spring core 5.1.2.RELEASE
  • Spring boot 2.1.0.RELEASE

With this controller without implements this Interface I can generate this API-doc:

@RestController
public class MissionApiImpl implements MissionApi {

  @Override
  @GetMapping("/test")
  public ResponseEntity<Void> test() {
    return new ResponseEntity( HttpStatus.OK );
  }
}

Generated doc:

{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":
[{"url":"http://localhost:9000/mgb/v6.0.0","description":"Generated server url"}],"paths":{"/test":
{"get":{"tags":["mission-api-impl"],"operationId":"test","responses":{"200":
{"description":"OK"}}}}},"components":{}}

But with this interface:

public interface MissionApi {

  ResponseEntity<Void> test();
}

I Have this error:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:890)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
    at org.springframework.web.method.HandlerMethod$HandlerMethodParameter.getParameterAnnotations(HandlerMethod.java:430)
    a

Any idea why?

I tried to migrate this Getter annotations to interface etc, but still the same error.

1 Answers

I had the same error with

springBootVersion = 2.1.1.RELEASE
springdocVersion = 1.5.9

and it's solved when I've upgraded to

springBootVersion = 2.1.3.RELEASE

So probably that was Spring Boot bug or bug in some Spring Boot dependencies

Related