Skip to content

Commit

Permalink
fix: update swagger dcumentation for PATCH dataset (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey authored Mar 8, 2024
1 parent 368bdc0 commit 7397786
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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;
}
Expand All @@ -53,35 +54,36 @@ 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(
@Parameter(description = "Dataset", required = true) @RequestBody String body) throws RmesException {
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,
@Parameter(description = "Dataset", required = true) @RequestBody String body) throws RmesException {
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);
}
}

0 comments on commit 7397786

Please sign in to comment.