Skip to content

Apply @Param expanders on QueryMap POJO fields and getters - #3658

Merged
velo merged 3 commits into
OpenFeign:masterfrom
havefunatcode:querymap-param-expander
Nov 9, 2026
Merged

velo merged 3 commits into
OpenFeign:masterfrom
havefunatcode:querymap-param-expander

Conversation

@havefunatcode

Copy link
Copy Markdown
Contributor

FieldQueryMapEncoder and BeanQueryMapEncoder only used @Param on a @QueryMap POJO for the name, so expander was ignored:

@Param(value = "since", expander = DateToMillis.class)
private final Date since; // sent as Date.toString()

Both encoders now create the expander once per class, next to the existing metadata cache, and apply it in encode. It's instantiated with newInstance() like method params are, and a failure throws EncodeException. An Iterable is expanded per element (null elements stay null), anything else (arrays too) goes to the expander as a whole, same as a method @Param. If the expander returns null the entry is dropped like a null field.

Also fixed @Param(expander = Foo.class) with no value, which sent the param with an empty name. It falls back to the field/property name now.

@HeaderMap POJOs use the same encoder, so header fields get their expanders too. Header POJOs without an expander are unchanged. Happy to limit it to query maps if you'd prefer.

Added defaultEncoder_withParamExpander to both encoder tests (they fail on master) and mvn -pl core test passes. README and CHANGELOG updated.

Fixes #1312

FieldQueryMapEncoder and BeanQueryMapEncoder now apply the @PARAM
expander, per element for an Iterable. A @PARAM without a value falls
back to the field or property name. @HeaderMap POJOs go through the
same encoders, so their expanders apply too.

Fixes OpenFeign#1312
@havefunatcode

Copy link
Copy Markdown
Contributor Author

@velo could you take a look when you get a chance? It fixes #1312. CircleCI is green. If it needs any changes, I can make them.

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good: expanders are built once per class next to the existing metadata cache, Iterable values are expanded per element like method @PARAM, a null expansion drops the entry, and the empty @PARAM name fallback is a nice fix. Tests fail on master as described. @havefunatcode #3613 just landed and touches FieldQueryMapEncoderTest, so this now conflicts there (just both test additions colliding). Could you merge master in? While at it, the #3612 CHANGELOG bullet that landed under 13.17 belongs in your new 13.18 section, if you don't mind moving it.

Signed-off-by: Marvin Froeder <velo.br@gmail.com>

# Conflicts:
#	CHANGELOG.md
#	core/src/test/java/feign/querymap/FieldQueryMapEncoderTest.java
@velo
velo enabled auto-merge (squash) November 9, 2026 20:48
@velo

velo commented Nov 9, 2026

Copy link
Copy Markdown
Member

Merged master and moved the CHANGELOG entry under the existing 13.18 heading. Also moved the #3612 HeaderMap bullet from 13.17 (already released) to 13.18, and kept both sets of tests in FieldQueryMapEncoderTest alongside #3613's static-field tests.

Signed-off-by: Marvin Froeder <velo.br@gmail.com>

# Conflicts:
#	CHANGELOG.md
@velo

velo commented Nov 9, 2026

Copy link
Copy Markdown
Member

Merged master; CHANGELOG.md was removed from the repo so the entry was dropped.

@velo
velo merged commit ce38f60 into OpenFeign:master Nov 9, 2026
3 checks passed
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

Successfully merging this pull request may close these issues.

FieldQueryMapEncoder uses Param.value but ignores Param.expander

2 participants