Skip to content

Commit

Permalink
fix: api-docs JSON example (#30)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lvarin authored Jan 24, 2023
1 parent 560fd03 commit df6446f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/main/java/uk/ac/ebi/tsc/tesk/tes/api/TasksApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ default ResponseEntity<TesCreateTaskResponse> 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. &#x60;MINIMAL&#x60;: Task message will include ONLY the fields: - &#x60;tesTask.Id&#x60; - &#x60;tesTask.State&#x60; &#x60;BASIC&#x60;: Task message will include all fields EXCEPT: - &#x60;tesTask.ExecutorLog.stdout&#x60; - &#x60;tesTask.ExecutorLog.stderr&#x60; - &#x60;tesInput.content&#x60; - &#x60;tesTaskLog.system_logs&#x60; &#x60;FULL&#x60;: 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(
Expand Down Expand Up @@ -124,7 +124,7 @@ default ResponseEntity<TesTask> getTask(@ApiParam(value = "ID of task to retriev
value = "/tasks",
produces = { "application/json" }
)
default ResponseEntity<TesListTasksResponse> 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<TesListTasksResponse> 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"))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ResponseEntity<TesTask> getTask(@ApiParam(value = "", required = true) @P
return new ResponseEntity<>(task, HttpStatus.OK);
}

public ResponseEntity<TesListTasksResponse> 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<TesListTasksResponse> 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<TesListTasksResponse>(response, HttpStatus.OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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


Expand Down
4 changes: 2 additions & 2 deletions src/main/java/uk/ac/ebi/tsc/tesk/tes/model/TesResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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<String> getZones() {
Expand Down

0 comments on commit df6446f

Please sign in to comment.