Java 招摇过市不挑选空值的方法

Java 招摇过市不挑选空值的方法,java,spring,rest,spring-mvc,swagger,Java,Spring,Rest,Spring Mvc,Swagger,我正在使用swagger来记录我的restapi 例如: @RequestMapping(value = "/abc/api/fruit", produces = "application/json") @Controller @Api(value = "Fruit", description = "api for fruits", produces = "application/json") public class FruitResource { @RequestMapping(meth

我正在使用swagger来记录我的restapi

例如:

@RequestMapping(value = "/abc/api/fruit", produces = "application/json")
@Controller
@Api(value = "Fruit", description = "api for fruits", produces =  "application/json")
public class FruitResource {

@RequestMapping(method = RequestMethod.GET, value = "")
@ResponseBody
@ApiOperation(httpMethod = "GET", value = "Resource to get fruits", produces = "application/json", notes = "get fruits", response=Fruit.class)
public ResponseEntity<Fruit> getFruits() throws Exception {
    return new ResponseEntity<Fruit>(someServiceCallToGetFruits(), HttpStatus.OK);
}
}
它开始工作了


这是虫子吗?如何使swagger使用路径值。我不想把
“/”
放在所有这些方法之上

如果不想为特定方法添加扩展API路径,则无需显式指定空值。相反,可以使用以下注释:

@RequestMapping(method = RequestMethod.GET)
甚至

@GetMapping()

如果不想为特定方法添加扩展API路径,则无需显式指定空值。相反,可以使用以下注释:

@RequestMapping(method = RequestMethod.GET)
甚至

@GetMapping()

您是否尝试过不指定空值?像
@RequestMapping(method=RequestMethod.GET)
@GetMapping()
?这里的
@RequestMapping
是spring注释吗?同样,当它与value=“/”一起工作时,在swagger上显示的完整路径是什么?@AlekseiBudiak:有效。。谢谢@尼克,很高兴这有帮助!您是否尝试过不指定空值?像
@RequestMapping(method=RequestMethod.GET)
@GetMapping()
?这里的
@RequestMapping
是spring注释吗?同样,当它与value=“/”一起工作时,在swagger上显示的完整路径是什么?@AlekseiBudiak:有效。。谢谢@尼克,很高兴这有帮助!