OpenFeign / OpenFeign/feign

Is not record class supported when using `@SpringQueryMap`?

Open
#1,927 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feedback provided spring-cloud
Dominant language
Java
Stars
9.8k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
41

Description

Hello.
When the @SpringQueryMap parameter is apllied as record class, http query is not recognized.
Is there some plan or has it already been updated?

using feign version

  • feign-core: 11.10
  • feign-form-spring: 3.8.0

test result

summary
  • If there is no getter (field accessor starting with get) when defining the class used in '@SpringQueryMap', it will not be recognized by feign
test type
  • record class
  • record class + get acessor
  • normal + getter
test report
record class

record class

public record PostQueryRecord(Long postId) {
}

feign method

@GetMapping("/comments")
void getCommentsRecord(@SpringQueryMap PostQueryRecord query);

result: query parameter is not recognized

[TestFeingClient#getCommentsRecord] ---> GET https://jsonplaceholder.typicode.com/comments HTTP/1.1
record class + adding get accessor

record class + get accessor

public record PostQueryRecordGetter(Long postId) {
    public Long getPostId() {
        return postId;
    }
}

feign method

@GetMapping("/comments")
void getCommentsRecordGetter(@SpringQueryMap PostQueryRecordGetter query);

result: query parameter is recognized

[TestFeingClient#getCommentsRecordGetter] ---> GET https://jsonplaceholder.typicode.com/comments?postId=1 HTTP/1.1
normal class + getter accesor

normal class

@Getter
@RequiredArgsConstructor
public class PostQueryClass {
    private final Long postId;
}

feign method

@GetMapping("/comments")
void getCommentsRecord(@SpringQueryMap PostQueryClass query);

result: query parameter is recognized

[TestFeingClient#getCommentsRecord] ---> GET https://jsonplaceholder.typicode.com/comments?postId=1 HTTP/1.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the @SpringQueryMap entry point and reproduce the record class, record-with-getter, and normal-class examples from the issue. Trace how query properties are discovered and add a regression test for the record accessor; done means PostQueryRecord produces the postId query parameter like the other examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.