I'm using Swagger2 with Springfox and Spring Boot. I have an endpoint defined like so:
@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());
}
The generated API docs are showing the id
of Store
in the Model Schema. Technically, when creating a Store
the JSON should not contain the id
. I'm trying to figure out how to tell Swagger/Springfox to ignore the id
but only for this endpoint.