Skip to content

Commit

Permalink
Fix OpenAPI annotations for existing endpoints (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
emerkle826 authored Aug 10, 2023
1 parent c62dbb5 commit 028c220
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 37 deletions.
131 changes: 106 additions & 25 deletions management-api-server/doc/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,21 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "Role created"
},
"400" : {
"content" : {
"text/plain" : {
"example" : "Username is empty"
"example" : "Username is empty",
"schema" : {
"type" : "string"
}
}
},
"description" : "Username and/or password is empty"
Expand Down Expand Up @@ -422,7 +428,13 @@
"200" : {
"content" : {
"application/json" : {
"example" : [ "system_schema", "system", "system_auth", "system_distributed", "system_traces" ]
"example" : [ "system_schema", "system", "system_auth", "system_distributed", "system_traces" ],
"schema" : {
"type" : "array",
"items" : {
"type" : "string"
}
}
}
},
"description" : "List of Keyspaces"
Expand All @@ -447,15 +459,21 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "Keyspace Replication Settings altered successfully"
},
"400" : {
"content" : {
"text/plain" : {
"example" : "Altering Keyspace failed. Non-empty 'keyspace_name' must be provided"
"example" : "Altering Keyspace failed. Non-empty 'keyspace_name' must be provided",
"schema" : {
"type" : "string"
}
}
},
"description" : "Keyspace name or Replication Settings not provided"
Expand Down Expand Up @@ -508,15 +526,21 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "Keyspace created successfully"
},
"400" : {
"content" : {
"text/plain" : {
"example" : "Keyspace creation failed. Non-empty 'keyspace_name' must be provided"
"example" : "Keyspace creation failed. Non-empty 'keyspace_name' must be provided",
"schema" : {
"type" : "string"
}
}
},
"description" : "Keyspace name or Replication Settings not provided"
Expand Down Expand Up @@ -545,15 +569,21 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "SSTables loaded successfully"
},
"400" : {
"content" : {
"text/plain" : {
"example" : "Must provide a keyspace name"
"example" : "Must provide a keyspace name",
"schema" : {
"type" : "string"
}
}
},
"description" : "Keyspace name or Table name not provided"
Expand All @@ -580,6 +610,9 @@
"example" : {
"class" : "org.apache.cassandra.locator.SimpleStrategy",
"replication_factor" : "2"
},
"schema" : {
"type" : "string"
}
}
},
Expand All @@ -588,15 +621,21 @@
"400" : {
"content" : {
"text/plain" : {
"example" : "Get keyspace replication failed. Non-empty 'keyspaceName' must be provided"
"example" : "Get keyspace replication failed. Non-empty 'keyspaceName' must be provided",
"schema" : {
"type" : "string"
}
}
},
"description" : "Keyspace name not provided"
},
"404" : {
"content" : {
"text/plain" : {
"example" : "Get keyspace replication failed. Keyspace 'my_keyspace' does not exist."
"example" : "Get keyspace replication failed. Keyspace 'my_keyspace' does not exist.",
"schema" : {
"type" : "string"
}
}
},
"description" : "Keyspace name not found"
Expand Down Expand Up @@ -1177,15 +1216,21 @@
"200" : {
"content" : {
"application/json" : {
"example" : [ "table_1", "table_2" ]
"example" : [ "table_1", "table_2" ],
"schema" : {
"type" : "string"
}
}
},
"description" : "Table list"
},
"400" : {
"content" : {
"text/plain" : {
"example" : "List tables failed. Non-empty 'keyspaceName' must be provided"
"example" : "List tables failed. Non-empty 'keyspaceName' must be provided",
"schema" : {
"type" : "string"
}
}
},
"description" : "Keyspace name not provided"
Expand All @@ -1210,15 +1255,21 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "Table compaction successful"
},
"400" : {
"content" : {
"text/plain" : {
"example" : "Invalid option combination: Can not use split-output here"
"example" : "Invalid option combination: Can not use split-output here",
"schema" : {
"type" : "string"
}
}
},
"description" : "Invalid table compaction request"
Expand All @@ -1243,15 +1294,21 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "Table creation successful"
},
"400" : {
"content" : {
"text/plain" : {
"example" : "Table creation failed: some failure message"
"example" : "Table creation failed: some failure message",
"schema" : {
"type" : "string"
}
}
},
"description" : "Table creation failed"
Expand All @@ -1276,7 +1333,10 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "Table flush successful"
Expand Down Expand Up @@ -1308,15 +1368,21 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "Table garbage collection successful"
},
"400" : {
"content" : {
"text/plain" : {
"example" : "tombstoneOption must be either ROW or CELL"
"example" : "tombstoneOption must be either ROW or CELL",
"schema" : {
"type" : "string"
}
}
},
"description" : "Invalid table garbage collection request"
Expand All @@ -1341,7 +1407,10 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "Table scrub successful"
Expand Down Expand Up @@ -1373,7 +1442,10 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "SSTable upgrade successful"
Expand Down Expand Up @@ -1428,7 +1500,10 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "Service is running"
Expand All @@ -1444,7 +1519,10 @@
"200" : {
"content" : {
"text/plain" : {
"example" : "OK"
"example" : "OK",
"schema" : {
"type" : "string"
}
}
},
"description" : "Service is ready to handle requests"
Expand Down Expand Up @@ -1554,7 +1632,10 @@
"200" : {
"content" : {
"application/json" : {
"example" : "{2207c2a9-f598-3971-986b-2926e09e239d: [10.244.1.4, 10.244.2.3, 10.244.3.3]}"
"example" : "{2207c2a9-f598-3971-986b-2926e09e239d: [10.244.1.4, 10.244.2.3, 10.244.3.3]}",
"schema" : {
"type" : "string"
}
}
},
"description" : "Gets the schema versions for each node. Useful for checking schema agreement"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
Expand All @@ -38,13 +39,18 @@ public AuthResources(ManagementApplication application) {
@ApiResponse(
responseCode = "200",
description = "Role created",
content = @Content(mediaType = MediaType.TEXT_PLAIN, examples = @ExampleObject(value = "OK")))
content =
@Content(
mediaType = MediaType.TEXT_PLAIN,
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = "OK")))
@ApiResponse(
responseCode = "400",
description = "Username and/or password is empty",
content =
@Content(
mediaType = MediaType.TEXT_PLAIN,
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = "Username is empty")))
public Response createRole(
@QueryParam(value = "username") String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public K8OperatorResources(ManagementApplication application) {
@ApiResponse(
responseCode = "200",
description = "Service is running",
content = @Content(mediaType = MediaType.TEXT_PLAIN, examples = @ExampleObject(value = "OK")))
content =
@Content(
mediaType = MediaType.TEXT_PLAIN,
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = "OK")))
public Response checkLiveness() {
return Response.ok("OK").build();
}
Expand All @@ -66,7 +70,11 @@ public Response checkLiveness() {
@ApiResponse(
responseCode = "200",
description = "Service is ready to handle requests",
content = @Content(mediaType = MediaType.TEXT_PLAIN, examples = @ExampleObject(value = "OK")))
content =
@Content(
mediaType = MediaType.TEXT_PLAIN,
schema = @Schema(implementation = String.class),
examples = @ExampleObject(value = "OK")))
@ApiResponse(responseCode = "500", description = "Service is not ready to handle requests")
public Response checkReadiness() {
return handle(
Expand Down
Loading

0 comments on commit 028c220

Please sign in to comment.