hikaku icon indicating copy to clipboard operation
hikaku copied to clipboard

Spring endpoints not discovered, `RequestMappingInfo.patternsCondition` returns null

Open aSemy opened this issue 3 years ago • 0 comments

Setup information

hikaku version: 3.3.0 specification converter: OpenAPI implementation converter: Spring build tool and version: Gradle 7.4.2 test framework: JUnit 5.8

Spring Boot 2.6.6, Spring WebMVC: 5.3.18

Describe the bug

I've copied the test from the README, but I get this error

👀 Expected, but unable to find:
<list of all endpoints>

https://github.com/codecentric/hikaku/blob/b8a754f91b524b53a464167bf0abd6044caa25a4/spring/src/main/kotlin/de/codecentric/hikaku/converters/spring/extensions/PathsSpringExtension.kt#L5-L7

I've stepped through the code and I can see that patternsCondition returns null. In the Javadoc I see:

This is mutually exclusive with {@link #getPathPatternsCondition()} such that when one returns {@code null} the other one returns an instance.

I can see pathPatternsCondition seems to return the endpoint correctly.

Expected behavior

Hikaku can discover the endpoints defined in Spring

Code samples

The rest controllers are defined like this

import org.springframework.http.MediaType.APPLICATION_JSON_VALUE
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/my-api")
class MyRestController {

    @GetMapping(
        value = ["/some/endpoint"],
        produces = [APPLICATION_JSON_VALUE]
    )
    fun getDetails(
        id: String
    ): ResponseEntity<ResponseModel> {
        //...
    }
}

aSemy avatar Apr 21 '22 12:04 aSemy