0
我使用Swagger2與Springfox和Spring Boot。我有像這樣限定的端點:ID不應該顯示模型架構與Swagger + Spring
@ApiOperation(value = "save", nickname = "Save Store")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Created"),
@ApiResponse(code = 401, message = "Unauthorized"),
@ApiResponse(code = 403, message = "Forbidden"),
@ApiResponse(code = 500, message = "Failure", response = ErrorResource.class)})
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public void save(@Valid @RequestBody Store store, BindingResult bindingResult, HttpServletRequest request, HttpServletResponse response) {
if (bindingResult.hasErrors()) {
throw new InvalidRequestException("Invalid Store", bindingResult);
}
this.storeService.save(store);
response.setHeader("Location", request.getRequestURL().append("/").append(store.getId()).toString());
}
所生成的API文檔中示出了在模型模式的Store
的id
。從技術上講,在創建Store
時,JSON不應包含id
。我試圖弄清楚如何告訴Swagger/Springfox忽略id
,但僅限於此端點。
是的,那不是我所需要的。我昨天使用'@ JsonView'找出了它。我會發布我自己的答案。 (還是)感謝你的建議。 – Gregg
你對@Gregg做了什麼? JsonView似乎不起作用。 – NeilS