From 73977867761bf58b2abed12e50203d93f54af720 Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Fri, 8 Mar 2024 14:18:24 +0100 Subject: [PATCH] fix: update swagger dcumentation for PATCH dataset (#536) --- .../webservice/dataset/DatasetResources.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/insee/rmes/webservice/dataset/DatasetResources.java b/src/main/java/fr/insee/rmes/webservice/dataset/DatasetResources.java index f1a794c5c..2a67b5013 100644 --- a/src/main/java/fr/insee/rmes/webservice/dataset/DatasetResources.java +++ b/src/main/java/fr/insee/rmes/webservice/dataset/DatasetResources.java @@ -17,6 +17,9 @@ import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.http.MediaType.TEXT_PLAIN; + @RestController @RequestMapping("/datasets") @SecurityRequirement(name = "bearerAuth") @@ -26,8 +29,6 @@ public class DatasetResources { final DatasetService datasetService; - public final String EXAMPLE_NUMBER_OF_OBSERVATION = "{\"observationNumber\":1}"; - public DatasetResources(DatasetService datasetService) { this.datasetService = datasetService; } @@ -53,7 +54,7 @@ public String getDistributionsByDataset(@PathVariable(Constants.ID) String id) t return this.datasetService.getDistributions(id); } - @PostMapping(value = "", consumes = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "", consumes = APPLICATION_JSON_VALUE) @Operation(operationId = "createDataset", summary = "Create a Dataset") @ResponseStatus(HttpStatus.CREATED) public String setDataset( @@ -61,7 +62,7 @@ public String setDataset( return this.datasetService.create(body); } - @PutMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE) + @PutMapping(value = "/{id}", consumes = APPLICATION_JSON_VALUE) @Operation(operationId = "updateDataset", summary = "Update a Dataset") public String setDataset( @PathVariable("id") String datasetId, @@ -69,19 +70,20 @@ public String setDataset( return this.datasetService.update(datasetId, body); } - @GetMapping(value = "/archivageUnits", consumes = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "/archivageUnits", consumes = APPLICATION_JSON_VALUE) @Operation(operationId = "getArchivageUnits", summary = "Get all archivage units") public String getArchivageUnits() throws RmesException { return this.datasetService.getArchivageUnits(); } - @PatchMapping(value = "/{id}/observationNumber", consumes = MediaType.APPLICATION_JSON_VALUE) - @Operation(operationId = "updateObservationNumber", summary = "Update ObsevationNumber of a dataset") + @PatchMapping(value = "/{id}/observationNumber", consumes = APPLICATION_JSON_VALUE) + @Operation(operationId = "updateObservationNumber", summary = "Update Observation number of a dataset") public void patchDataset( @PathVariable("id") String datasetId, - @Schema(name ="observationNumber",example = EXAMPLE_NUMBER_OF_OBSERVATION ) - @Parameter(description = "Dataset", required = true) @RequestBody String observationNumber + @Schema(name ="observationNumber", example = "1" ) + @Parameter(description = "Dataset", required = true) + @RequestBody String observationNumber ) throws RmesException{ - this.datasetService.patchDataset(datasetId,observationNumber); + this.datasetService.patchDataset(datasetId, observationNumber); } } \ No newline at end of file