@GetMapping(value = "/result")
public int addition(
@ApiParam(value = "FirstValue", required = true, type = "string", defaultValue = "0") @RequestParam(value = "firstValue", required = true) Integer x,
@ApiParam(value = "SecondValue", required = true, type = "string", defaultValue = "0") @RequestParam(value = "secondValue", required = true) Integer y) {
return x + y;
}
while refresh the swagger UI page we are getting following error
2019-06-26 15:44:11.484 WARN 16667 --- [nio-7854-exec-3] i.s.m.p.AbstractSerializableParameter : Illegal DefaultValue 0 for parameter type integer
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_144]
at java.lang.Long.parseLong(Long.java:601) ~[na:1.8.0_144]
at java.lang.Long.valueOf(Long.java:803) ~[na:1.8.0_144]
at io.swagger.models.parameters.AbstractSerializableParameter.getExample(AbstractSerializableParameter.java:412) ~[swagger-models-1.5.20.jar:1.5.20]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
Integer
but the annotations saytype="string"
. Have you tried changing the annotations totype="integer"
? – Hepler