From 06f50ae2aecfbabb0998ba2a036217f6203c1161 Mon Sep 17 00:00:00 2001 From: ilkerkocatepe Date: Sun, 22 Sep 2024 00:00:46 +0300 Subject: [PATCH] [#434] feat: added create topic endpoint - openapiv2.json edits and tests Signed-off-by: ilkerkocatepe --- src/main/resources/openapiv2.json | 42 +++++++++++++++++++ .../kafka/bridge/http/OtherServicesIT.java | 2 + 2 files changed, 44 insertions(+) diff --git a/src/main/resources/openapiv2.json b/src/main/resources/openapiv2.json index a5e4eab7..a0089a14 100644 --- a/src/main/resources/openapiv2.json +++ b/src/main/resources/openapiv2.json @@ -686,6 +686,48 @@ } ] }, + "/create-topic/{topicname}": { + "post": { + "tags": [ + "Topics" + ], + "description": "Creates a topic with given topic name.", + "operationId": "createTopic", + "responses": { + "200": { + "description": "Topic metadata", + "schema": { + "$ref": "#/definitions/TopicMetadata" + } + }, + "404": { + "description": "The specified topic was not found.", + "schema": { + "$ref": "#/definitions/Error" + }, + "examples": { + "response": { + "value": { + "error_code": 404, + "message": "The specified topic was not found." + } + } + } + } + } + }, + "parameters": [ + { + "name": "topicname", + "in": "path", + "description": "Name of the topic to send records to or retrieve metadata from.", + "required": true, + "schema": { + "type": "string" + } + } + ] + }, "/consumers/{groupid}/instances/{name}/records": { "get": { "tags": [ diff --git a/src/test/java/io/strimzi/kafka/bridge/http/OtherServicesIT.java b/src/test/java/io/strimzi/kafka/bridge/http/OtherServicesIT.java index 7586ea7c..6f3d395a 100644 --- a/src/test/java/io/strimzi/kafka/bridge/http/OtherServicesIT.java +++ b/src/test/java/io/strimzi/kafka/bridge/http/OtherServicesIT.java @@ -151,6 +151,8 @@ void openapiTest(VertxTestContext context) { assertThat(paths.containsKey("/topics/{topicname}/partitions/{partitionid}/offsets"), is(true)); assertThat(paths.containsKey("/topics/{topicname}/partitions"), is(true)); assertThat(bridgeResponse.getJsonObject("paths").getJsonObject("/topics/{topicname}/partitions/{partitionid}").getJsonObject("post").getString("operationId"), is(HttpOpenApiOperations.SEND_TO_PARTITION.toString())); + assertThat(paths.containsKey("/create-topic/{topicname}"), is(true)); + assertThat(bridgeResponse.getJsonObject("paths").getJsonObject("/create-topic/{topicname}").getJsonObject("post").getString("operationId"), is(HttpOpenApiOperations.CREATE_TOPIC.toString())); assertThat(paths.containsKey("/healthy"), is(true)); assertThat(bridgeResponse.getJsonObject("paths").getJsonObject("/healthy").getJsonObject("get").getString("operationId"), is(HttpOpenApiOperations.HEALTHY.toString())); assertThat(paths.containsKey("/ready"), is(true));