spring-projects / spring-projects/spring-hateoas
Request parameters are omitted from templated url when they are required and have a default value.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
@RequestMapping(path="/greet")
public HttpEntity<ResourceSupport> greeting(
@RequestParam(value = "param1", defaultValue = "hello") String param1,
@RequestParam(value = "param2", defaultValue = "default2") String param2) {
ResourceSupport resource = new ResourceSupport();
resource.add(linkTo(methodOn(ExampleController.class).greeting(null, null).withSelfRel());
return new ResponseEntity<ResourceSupport>(resource, HttpStatus.OK);
}
I am getting,
{
"_links": {
"self": {
"href": "http://localhost:8082/greet"
}
}
}
while I am expecting,
{
"_links": {
"self": {
"href": "http://localhost:8082/greet?param1={param1}¶m2={param2}",
"templated": true
}
}
}
is this the expected behaviour or am I missing something?
#169
Templating just works fine when I have optional request params with default values, but they are omitted when they are required and have default values.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the @RequestMapping /greet controller using the @RequestParam arguments and the linkTo(methodOn(ExampleController.class).greeting(null, null)) entry point. Compare the generated link with the expected templated URL, including both required parameters with default values; done means the behavior is clarified or corrected and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100