-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Milestone
Description
I've setup a endpoint that takes a POST, and returns a 201. If you set this up as:
@ApiOperation(value = "Create a new thing",
notes = "Insert a new thing into the system"
)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Thing failed validation", response = ValidationException.class)})
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Thing> newThing(@RequestBody Thing thing) {
Thing insertedThing = thingService.insertThing(thing);
return new ResponseEntity<Thing>(thing, HttpStatus.CREATED);
}
Then this generates as returning a 200 status code:
"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/Thing"}}
By contrast this:
@ApiOperation(value = "Create a new thing",
notes = "Insert a new thing into the system"
)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Thing failed validation", response = ValidationException.class)})
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value= HttpStatus.CREATED)
public Thing newThing(@RequestBody Thing thing) {
Thing insertedThing = thingService.insertThing(thing);
return insertedThing;
}
Seems to work fine. Should the ResponseEntity parameter be picked up?