0

I have to write an API call

@GET
@Path("/{settingName1, settingName2}")
public Response getNetworkSettingValue(@ApiParam(value = "Name") @QueryParam("name") String name,
        @ApiParam(value = "City") @QueryParam("city") String city,
        @ApiParam(value = "State") @QueryParam("state") String state) {}

here my doubt is how to get settingName1 & settingName2 values, can write like

@ApiParam(value = "SettingName1") @PathParam("settingName1") String settingName1

or

@ApiParam(value = "SettingName1") @PathVariable("settingName1") String settingName1

in method declaration.

or

any other way to get those two values

Sat
  • 3,520
  • 9
  • 39
  • 66
  • You could use both but I'd stick to the @PathParam. See also this question http://stackoverflow.com/questions/32367501/what-is-the-difference-between-pathparam-and-pathvariable – borowis Oct 18 '16 at 12:04
  • Let me know if my answer was useful for you. – cassiomolin Jan 24 '17 at 12:40

2 Answers2

0

By the @Path annotation, I assume you are using JAX-RS (Jersey, RESTEasy, etc). So it should be:

@ApiParam(value = "SettingName1") @PathParam("settingName1") String settingName1

If you were using Spring, it should be:

@ApiParam(value = "SettingName1") @PathVariable("settingName1") String settingName1
cassiomolin
  • 124,154
  • 35
  • 280
  • 359
0

your annotations are mixed up with spring and swagger.

If u want to accesss pathvariables with spring than it have to be like

@RequestMapping(value = "/{settingName1}/{settingName2}", method = equestMethod.GET)
public Response getNetworkSettingValue(@ApiParam(value = "settingName1") @PathVariable final String settingName1,
                                       @ApiParam(value = "settingName2") @PathVariable final String settingName2) {
...
     return new Response();
}