FieldQueryMapEncoder uses Param.value but ignores Param.expander
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.8k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 41
Description
The FieldQueryMapEncoder implementation uses the Param annotation to set the field names:
but it does not use its expander to set the value:
Was this done intentionally or could it be considered a bug?
I was hoping to use the @Param annotation on a POJO of optional query parameters with a field that needs custom encoding, e.g.:
package com.example.opts;
import com.example.expander.CustomExpander;
import feign.Param;
import lombok.Builder;
import lombok.Value;
import java.time.Instant;
@Builder
@Value
public class ExampleOptions {
@Param(value = "customValue", expander = CustomExpander.class)
Instant custom;
Long normal;
}
In this example the parameter is named "customValue", but the value is just the .toString() value of the java.time.Instant instead of the value CustomExpander would have returned.
Please feel free to close this if FieldQueryMapEncoder is meant to work this way. If that's the case, I think it'd make sense to have a custom QueryMapEncoder that uses the expander.
I'd be happy to create a pull request that uses the Param.expander if you think it makes sense.
Thanks,
Shaun
Contributor guide
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 with core/src/main/java/feign/querymap/FieldQueryMapEncoder.java, especially the handling of Param.value and Param.expander around lines 42-46. Verify how an ExampleOptions field is converted into a query parameter and whether the expander should determine its value. Done means the documented custom expander affects the encoded value while normal fields continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100