Skip to content

feignclient does not support non-required path variables #426

Open
@wolfsono

Description

@wolfsono

SpringCloud - 2.2.1

Issue Description -
I'm extending controller from another service using @FeignClient -

@FeignClient(name = "<NAME>", url = "<URL>")
public interface IMyController extends IFromAnotherServiceController {
}

in the other controller I have the following api definition -

   @ApiOperation(value = "", nickname = "getSomething")
    @ApiResponse(code = 200, message = "")
    @GetMapping(path= {"/api/get-something/a/{a}",
                         "/api/get-something/a/{a}/b/{b}",
                         "/api/get-something/a/{a}/b/{b}/c/{c}"})
    SomeDto getSomething(@PathVariable(name = "a") String a,
                                                     @PathVariable(required = false, name = "b") String b
                                                     @PathVariable(required = false, name = "c") String c); 

So i have only 1 path variable which is required, other 2 are optional.

I use this method getSomething in my code with 3 parameters this way :
client.getSomething(x, y, z); (while client is of type IMyController)

And when I try to start the application, I get the following error -

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '...IFromAnotherServiceController ': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Method getSomething can only contain at most 1 value field. Found: [/api/get-something/a/{a}, /api/get-something/a/{a}/b/{b}, /api/get-something/a/{a}/b/{b}/c/{c}]

Any idea what configuration am I missing? Why it enables me to call this method with 3 arguments but then at the start up it throws exception that i can use only 1?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions