spring-hateoas icon indicating copy to clipboard operation
spring-hateoas copied to clipboard

WebMvcLinkBuilder does not resolve "EmmbeddedValues" correctly.

Open FlameDuck opened this issue 3 years ago • 0 comments
trafficstars

When using "Embedded Values" in spring, WebMvcLinkBuilder does not correctly resolve the value. This does not seem to be an esoteric way of writing a RestController, as among other things this is how the OpenAPI generator generates server stubs.

Example:

@RestController
@RequestMapping("${openapi.example.base-path:/example}")
public class HelloController {
}

Failing Test:

@Test
void LinkBuilderAndSpringEmbeddedValueResolver() {
    var result = WebMvcLinkBuilder.linkTo(HelloController.class)
                    .withRel("example");
    assertThat(result).extracting(Link::getHref).isEqualTo("http://localhost/example");
}

Result:

expected: "http://localhost/example"
 but was: "http://localhost/example}"

FlameDuck avatar Sep 16 '22 08:09 FlameDuck