IntentArchitect / Support

A repository dedicated to handling issues and support queries
3 stars 0 forks source link

Create httpStatus sent back as 201 not 200 #42

Closed leonAtRain closed 1 year ago

leonAtRain commented 1 year ago

What problem are you trying to solve?

When CRUD operations are created I need to change the response to send back HttpStatus.CREATED instead of OK. In the documentation created by Swagger it mentions that 201 would be sent back, but then 200 is sent back:

@PostMapping @Operation(summary = "create") @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "Successfully created."), @ApiResponse(responseCode = "400", description = "One or more validation errors have occurred.") }) public ResponseEntity<?> create(@Valid @Parameter(required = true) @RequestBody BillCycleSpecificationDto dto) { final Object result = billCycleSpecificationService.create(dto); return new ResponseEntity<>(result, HttpStatus.OK); }

The override is available for me to do it manually, but I've got more than 120 to do, so I would really love to have this resolved from Intent side.

Describe the solution you'd like

Solution from my side would be - either have the default corrected to always return 201 for Create endpoint in CRUD - or add the "return HttpStatus" in the HttpSettings Stereo type - this way, I can also change the "Delete" endpoint to return something other than 200 as I need to return 204 with a Delete as well.

dandrejvv commented 1 year ago

Hi @leonAtRain . Good suggestion, it should be a quick and easy update. As soon as it is done I will inform you.

dandrejvv commented 1 year ago

Hi @leonAtRain. I have fixed the Open API module as well as the SpringBoot module so that their metadata and successful return status codes are consistent. There is a Intent.Java.SpringDoc.OpenApi (1.0.5-pre.1) and Intent.Java.SpringBoot (3.5.0-pre.1) that you can update and test on your end. Please let me know if this works for you.

leonAtRain commented 1 year ago

Hi @dandrejvv, Much appreciated - will update my side, and let you know soon, going to test it out momentarily.

leonAtRain commented 1 year ago

Applied the new version to my code, rebuilt all the modules and they all work fine, thank you - appreciate the quick response on this.