-
Notifications
You must be signed in to change notification settings - Fork 472
Support for non-composite request parameter rendering on link creation #1575
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
Comments
Can you elaborate what kind of specification you're referring to and where this YAML excerpt comes from? I don't think the format you expect is actually a valid expectation as there's nothing in any URI spec that specifies a comma separated This isn't even Spring HATEOAS specific. If you issue a request using a comma separated |
The spec I mentioned was an OpenAPI spec for the project, as described in OpenAPI - Parameter Serialization. As for the URI spec, it is mentioned for example in the following sections:
I was aiming for the first example for lists (<parameter>=<comma separated values>). If I should open the issue for spring itself please let me know. Thank you for the quick reply and support. |
We definitely have to talk to the core framework team here. There currently is no way to actually produce a comma separated parameter list via Just for reference: the sections you quote are from the URI Template RFC, not from the URI one. I only checked the latter as I assumed the URI parameter parsing within the
The latter two are symmetric. Passing the value directly into Regarding OpenAPI spec. There's no out of the box integration with that spec on neither MVC nor HATEOAS level. Are you using any kind of third-party integration library? |
Should I open an issue there and link to this one? Or how should I proceed with this?
Yes, this is something that would be missing. Ideally it should be a configuration for each parameter, but I would assume that implementations for an API would be consistent and use just one approach. So a global setting for this behavior could be enough.
No, we are doing it by hand (not even generating java code from the spec). |
@odrotbohm How can we proceed with this? |
With #1583 in place, we might be able to solve this using a custom annotation (e.g. |
This commit introduces @NonComposite, an annotation to be used with collection or array typed @RequestParam handler method parameters. Using the annotation causes the rendering of request parameters to use the non-composite way of rendering URI template values (param=value1,value2) rather than the default, composite flavor of param=value1¶m=value2. A bit of polish in TemplateVariable, which now also exposes a prepareAndEncode(Object) method that renders a given value according to the rules defined in the URI template spec for the particular variable type and state (composite VS. non-composite).
The 1.4 snapshots should support this via |
Using Spring HATEOAS does not seem to allow to match specs configured to explode arrays:
I am generating the links as follows:
Calling the endpoint with
http://localhost:8080/cars?make=Renault,BMW
gives the response response like:The link is
http://localhost:8080/cars?make=Renault&make=BMW
but should behttp://localhost:8080/cars?make=Renault,BMW"
Debugging the code from org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo reaches HierarchicalUriComponents.getQuery which always duplicates the query variable name for each value.
Trying to change the behaviour of WebMvcLinkBuilder by creating a custom one seems to need a lot of code duplication. Maybe there is a better way to achieve this, but it would be better to have it done in a simple way (e.g. like using a spring configuration).
The text was updated successfully, but these errors were encountered: