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

AffordanceBuilderFactory does not use value of a @RequestParam #28

Closed
rgacki opened this issue Aug 7, 2017 · 1 comment
Closed

AffordanceBuilderFactory does not use value of a @RequestParam #28

rgacki opened this issue Aug 7, 2017 · 1 comment
Assignees

Comments

@rgacki
Copy link

rgacki commented Aug 7, 2017

I have a controller method with arguments annotated with @RequestParam, like this:

@GetMapping(produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView showAsHtml(final @RequestParam("q") String query,
                               final @RequestParam(value = "offset", defaultValue = "0") Long offset,
                               final Locale locale) {
  // do stuff
}

Now I build an Affordance that is an URI template:

AffordanceBuilder.linkTo(AffordanceBuilder.methodOn(MyController.class)
        .showAsHtml(null, null, null))
        .rel("something")
        ...;

The serialized hydra:IriTemplate will look like this:

{
    "@type": "hydra:IriTemplate",
    "hydra:template": "http://localhost:8080/something{?query}",
    "hydra:mapping": [
      {
        "@type": "hydra:IriTemplateMapping",
        "hydra:variable": "query",
        "hydra:required": true,
        "hydra:property": "query"
      }
    ]
  }

So the variable "query" is wrong. It should be "q" as defined by the @RequestParam.

@dschulten dschulten self-assigned this Mar 20, 2018
@dschulten
Copy link
Owner

fixed as of 0.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants