From df6446f9add415380360b43f5c8b96d5a0f1fd76 Mon Sep 17 00:00:00 2001 From: Alvaro Gonzalez Date: Tue, 24 Jan 2023 10:53:06 +0200 Subject: [PATCH] fix: api-docs JSON example (#30) * Add junit deps * Fix api-docs JSON example The api-docs json definition of the API was not passing the JSON parsing. One of the examples (in colunm ~1580, with text us-west-1), needed quotes * Upgrade springfox-swagger to fix swagger API deffinition * Few other changes to make it more compatible * Fix missing dependencies --- src/main/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApi.java | 6 +++--- .../java/uk/ac/ebi/tsc/tesk/tes/api/TasksApiController.java | 2 +- .../uk/ac/ebi/tsc/tesk/tes/model/TesCreateTaskResponse.java | 2 +- .../java/uk/ac/ebi/tsc/tesk/tes/model/TesExecutorLog.java | 2 +- src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutput.java | 2 +- .../java/uk/ac/ebi/tsc/tesk/tes/model/TesOutputFileLog.java | 4 ++-- .../java/uk/ac/ebi/tsc/tesk/tes/model/TesResources.java | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApi.java b/src/main/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApi.java index 01423fc..23b5e71 100644 --- a/src/main/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApi.java +++ b/src/main/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApi.java @@ -78,14 +78,14 @@ default ResponseEntity createTask(@ApiParam(value = "" ,r /** - * GET /tasks/{id} : GetTask + * GET /tasks/{id} : GetTaskInfo * Get a single task, based on providing the exact task ID string. * * @param id ID of task to retrieve. (required) * @param view OPTIONAL. Affects the fields included in the returned Task messages. `MINIMAL`: Task message will include ONLY the fields: - `tesTask.Id` - `tesTask.State` `BASIC`: Task message will include all fields EXCEPT: - `tesTask.ExecutorLog.stdout` - `tesTask.ExecutorLog.stderr` - `tesInput.content` - `tesTaskLog.system_logs` `FULL`: Task message includes all fields. (optional, default to MINIMAL) * @return (status code 200) */ - @ApiOperation(value = "GetTask", nickname = "getTask", notes = "Get a single task, based on providing the exact task ID string.", response = TesTask.class, tags={ "TaskService", }) + @ApiOperation(value = "GetTask", nickname = "GetTaskInfo", notes = "Get a single task, based on providing the exact task ID string.", response = TesTask.class, tags={ "TaskService", }) @ApiResponses(value = { @ApiResponse(code = 200, message = "", response = TesTask.class) }) @GetMapping( @@ -124,7 +124,7 @@ default ResponseEntity getTask(@ApiParam(value = "ID of task to retriev value = "/tasks", produces = { "application/json" } ) - default ResponseEntity listTasks(@ApiParam(value = "OPTIONAL. Filter the list to include tasks where the name matches this prefix. If unspecified, no task name filtering is done.") @Valid @RequestParam(value = "name_prefix", required = false) String namePrefix,@ApiParam(value = "Optional number of tasks to return in one page. Must be less than 2048. Defaults to 256.") @Valid @RequestParam(value = "page_size", required = false) Long pageSize,@ApiParam(value = "OPTIONAL. Page token is used to retrieve the next page of results. If unspecified, returns the first page of results. The value can be found in the `next_page_token` field of the last returned result of ListTasks") @Valid @RequestParam(value = "page_token", required = false) String pageToken,@ApiParam(value = "OPTIONAL. Affects the fields included in the returned Task messages. `MINIMAL`: Task message will include ONLY the fields: - `tesTask.Id` - `tesTask.State` `BASIC`: Task message will include all fields EXCEPT: - `tesTask.ExecutorLog.stdout` - `tesTask.ExecutorLog.stderr` - `tesInput.content` - `tesTaskLog.system_logs` `FULL`: Task message includes all fields.", allowableValues = "MINIMAL, BASIC, FULL", defaultValue = "MINIMAL") @Valid @RequestParam(value = "view", required = false, defaultValue="MINIMAL") String view) { + default ResponseEntity listTasks(@ApiParam(value = "OPTIONAL. Filter the list to include tasks where the name matches this prefix. If unspecified, no task name filtering is done.") @Valid @RequestParam(value = "name_prefix", required = false) String namePrefix,@ApiParam(example="256",value = "Optional number of tasks to return in one page. Must be less than 2048. Defaults to 256.") @Valid @RequestParam(value = "page_size", required = false) Long pageSize,@ApiParam(value = "OPTIONAL. Page token is used to retrieve the next page of results. If unspecified, returns the first page of results. The value can be found in the `next_page_token` field of the last returned result of ListTasks") @Valid @RequestParam(value = "page_token", required = false) String pageToken,@ApiParam(value = "OPTIONAL. Affects the fields included in the returned Task messages. `MINIMAL`: Task message will include ONLY the fields: - `tesTask.Id` - `tesTask.State` `BASIC`: Task message will include all fields EXCEPT: - `tesTask.ExecutorLog.stdout` - `tesTask.ExecutorLog.stderr` - `tesInput.content` - `tesTaskLog.system_logs` `FULL`: Task message includes all fields.", allowableValues = "MINIMAL, BASIC, FULL", defaultValue = "MINIMAL") @Valid @RequestParam(value = "view", required = false, defaultValue="MINIMAL") String view) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/src/main/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApiController.java b/src/main/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApiController.java index 60d60bc..62c39e8 100644 --- a/src/main/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApiController.java +++ b/src/main/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApiController.java @@ -51,7 +51,7 @@ public ResponseEntity getTask(@ApiParam(value = "", required = true) @P return new ResponseEntity<>(task, HttpStatus.OK); } - public ResponseEntity listTasks(@ApiParam(value = "OPTIONAL. Filter the list to include tasks where the name matches this prefix. If unspecified, no task name filtering is done.") @RequestParam(value = "name_prefix", required = false) String namePrefix, @ApiParam(value = "OPTIONAL. Number of tasks to return in one page. Must be less than 2048. Defaults to 256.") @RequestParam(value = "page_size", required = false) Long pageSize, @ApiParam(value = "OPTIONAL. Page token is used to retrieve the next page of results. If unspecified, returns the first page of results. See ListTasksResponse.next_page_token") @RequestParam(value = "page_token", required = false) String pageToken, @ApiParam(value = "OPTIONAL. Affects the fields included in the returned Task messages. See TaskView below. - MINIMAL: Task message will include ONLY the fields: Task.Id Task.State - BASIC: Task message will include all fields EXCEPT: Task.ExecutorLog.stdout Task.ExecutorLog.stderr Input.content TaskLog.system_logs - FULL: Task message includes all fields.", allowableValues = "MINIMAL, BASIC, FULL", defaultValue = "MINIMAL") @RequestParam(value = "view", required = false, defaultValue = "MINIMAL") String view) { + public ResponseEntity listTasks(@ApiParam(value = "OPTIONAL. Filter the list to include tasks where the name matches this prefix. If unspecified, no task name filtering is done.") @RequestParam(value = "name_prefix", required = false) String namePrefix, @ApiParam(example="256",value = "OPTIONAL. Number of tasks to return in one page. Must be less than 2048. Defaults to 256.") @RequestParam(value = "page_size", required = false) Long pageSize, @ApiParam(value = "OPTIONAL. Page token is used to retrieve the next page of results. If unspecified, returns the first page of results. See ListTasksResponse.next_page_token") @RequestParam(value = "page_token", required = false) String pageToken, @ApiParam(value = "OPTIONAL. Affects the fields included in the returned Task messages. See TaskView below. - MINIMAL: Task message will include ONLY the fields: Task.Id Task.State - BASIC: Task message will include all fields EXCEPT: Task.ExecutorLog.stdout Task.ExecutorLog.stderr Input.content TaskLog.system_logs - FULL: Task message includes all fields.", allowableValues = "MINIMAL, BASIC, FULL", defaultValue = "MINIMAL") @RequestParam(value = "view", required = false, defaultValue = "MINIMAL") String view) { TesListTasksResponse response = this.tesService.listTasks(namePrefix, pageSize, pageToken, TaskView.fromString(view), this.getUser()); return new ResponseEntity(response, HttpStatus.OK); diff --git a/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesCreateTaskResponse.java b/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesCreateTaskResponse.java index 5d9bf7f..dee4801 100644 --- a/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesCreateTaskResponse.java +++ b/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesCreateTaskResponse.java @@ -25,7 +25,7 @@ public TesCreateTaskResponse id(String id) { * Task identifier assigned by the server. * @return id */ - @ApiModelProperty(required = true, value = "Task identifier assigned by the server.") + @ApiModelProperty(required = true, value = "Task identifier assigned by the server.", example="task-e69c5b95") @NotNull diff --git a/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesExecutorLog.java b/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesExecutorLog.java index 44f7de6..452f299 100644 --- a/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesExecutorLog.java +++ b/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesExecutorLog.java @@ -117,7 +117,7 @@ public TesExecutorLog exitCode(Integer exitCode) { * Exit code. * @return exitCode */ - @ApiModelProperty(required = true, value = "Exit code.") + @ApiModelProperty(example="0", required = true, value = "Exit code.") @NotNull diff --git a/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutput.java b/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutput.java index 62612cb..7fcd2a8 100644 --- a/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutput.java +++ b/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutput.java @@ -102,7 +102,7 @@ public TesOutput path(String path) { * Path of the file inside the container. Must be an absolute path. * @return path */ - @ApiModelProperty(required = true, value = "Path of the file inside the container. Must be an absolute path.") + @ApiModelProperty(example = "/data/file1", required = true, value = "Path of the file inside the container. Must be an absolute path.") @NotNull @Pattern(regexp = ABSOLUTE_PATH_REGEXP, message = ABSOLUTE_PATH_MESSAGE) @NotBlank diff --git a/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutputFileLog.java b/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutputFileLog.java index ee249ef..5fa9877 100644 --- a/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutputFileLog.java +++ b/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutputFileLog.java @@ -31,7 +31,7 @@ public TesOutputFileLog url(String url) { * URL of the file in storage, e.g. s3://bucket/file.txt * @return url */ - @ApiModelProperty(required = true, value = "URL of the file in storage, e.g. s3://bucket/file.txt") + @ApiModelProperty(example="s3://bucket/file.txt", required = true, value = "URL of the file in storage, e.g. s3://bucket/file.txt") @NotNull @@ -52,7 +52,7 @@ public TesOutputFileLog path(String path) { * Path of the file inside the container. Must be an absolute path. * @return path */ - @ApiModelProperty(required = true, value = "Path of the file inside the container. Must be an absolute path.") + @ApiModelProperty(example="/data/file1", required = true, value = "Path of the file inside the container. Must be an absolute path.") @NotNull diff --git a/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesResources.java b/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesResources.java index d9faf68..b3fb3a8 100644 --- a/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesResources.java +++ b/src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesResources.java @@ -11,7 +11,7 @@ /** * Resources describes the resources requested by a task. */ -@ApiModel(description = "Resources describes the resources requested by a task.") +@ApiModel(description = "Resources describes the resources requested by a task.", value="tesResources") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2021-03-24T17:10:08.716Z[Europe/London]") public class TesResources { @JsonProperty("cpu_cores") @@ -127,7 +127,7 @@ public TesResources addZonesItem(String zonesItem) { * Request that the task be run in these compute zones. How this string is utilized will be dependent on the backend system. For example, a system based on a cluster queueing system may use this string to define priorty queue to which the job is assigned. * @return zones */ - @ApiModelProperty(example = "[us-west-1]", value = "Request that the task be run in these compute zones. How this string is utilized will be dependent on the backend system. For example, a system based on a cluster queueing system may use this string to define priorty queue to which the job is assigned.") + @ApiModelProperty(example = "[\"us-west-1\"]", value = "Request that the task be run in these compute zones. How this string is utilized will be dependent on the backend system. For example, a system based on a cluster queueing system may use this string to define priorty queue to which the job is assigned.") public List getZones() {