Micronaut-core: QueryValue annotation on declarative client produces wrong URL query parameters

Created on 11 Dec 2019  路  2Comments  路  Source: micronaut-projects/micronaut-core

Creating a client which receives a List query parameter, while using a @QueryValue annotation produces the wrong output.

Example:

@Get("/api/v1/stuff{?name*}")
public Object functionName(@QueryValue(value = "name") List<String> name);

Calling this client with a list containing ABC, DEF:

  • Output URL produced will be: http://localhost:51008/api/v1/stuff?name=ABC,DEF
  • Expected output should be: ://localhost:51008/api/v1/stuff?name=ABC&namespace=DEF

Workaround for this issue is removing the @QueryValue annotation.

@Get("/api/v1/stuff{?name*}")
public Object functionName(List<String> name);

Calling this client with a list containing ABC, DEF:

  • Output URL produced will be ://localhost:51008/api/v1/stuff?name=ABC&namespace=DEF as expected.

Tested using 1.2.2 and 1.2.7 Micronaut versions.

bug

Most helpful comment

@RuiffCardoso I am sorry it seem like my sample is replicating the problem and got confused with something else. I will look into fixing the same.

All 2 comments

@RuiffCardoso It works with the following:

@Client("/stuff")
public interface StuffClient {

    @Get("{?names*}")
    HttpResponse<List<Stuff>> get(@QueryValue("names") List<String> names);
}

Edit: Here is the sample application
wrongqueryparameters.zip

@RuiffCardoso I am sorry it seem like my sample is replicating the problem and got confused with something else. I will look into fixing the same.

Was this page helpful?
0 / 5 - 0 ratings