Skip to content

Commit c88f45c

Browse files
committed
Add Webhook annotation TCK
1 parent 569257c commit c88f45c

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tck/src/main/java/org/eclipse/microprofile/openapi/apps/airlines/JAXRSApp.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition;
2323
import org.eclipse.microprofile.openapi.annotations.callbacks.Callback;
2424
import org.eclipse.microprofile.openapi.annotations.callbacks.CallbackOperation;
25+
import org.eclipse.microprofile.openapi.annotations.callbacks.Webhook;
2526
import org.eclipse.microprofile.openapi.annotations.enums.ParameterIn;
2627
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
2728
import org.eclipse.microprofile.openapi.annotations.enums.SecuritySchemeIn;
@@ -107,6 +108,26 @@
107108
extensions = @Extension(name = "x-server", value = "test-server")),
108109
@Server(url = "https://test-server.com:80/basePath", description = "The test API server")
109110
},
111+
webhooks = {
112+
@Webhook(name = "bookingEvent",
113+
description = "Notifies about booking creation and deletion",
114+
summary = "Booking Events",
115+
operations = {
116+
@CallbackOperation(method = "put",
117+
summary = "Notifies that a booking has been created",
118+
requestBody = @RequestBody(content = @Content(mediaType = "application/json",
119+
schema = @Schema(ref = "#/components/schemas/Booking"))),
120+
responses = @APIResponse(responseCode = "204",
121+
description = "Indicates that the creation event was processed successfully")),
122+
@CallbackOperation(method = "delete",
123+
summary = "Notifies that a booking has been deleted",
124+
requestBody = @RequestBody(content = @Content(mediaType = "application/json",
125+
schema = @Schema(ref = "#/components/schemas/Booking"))),
126+
responses = @APIResponse(responseCode = "204",
127+
description = "Indicates that the deletion event was processed successfully"))
128+
},
129+
extensions = @Extension(name = "x-webhook", value = "test-webhook"))
130+
},
110131
components = @Components(
111132
schemas = {
112133
@Schema(name = "Bookings", title = "Bookings",

tck/src/main/java/org/eclipse/microprofile/openapi/tck/AirlinesAppTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,4 +1128,29 @@ public void testOpenAPIDefinitionExtension(String type) {
11281128
vr.body("x-openapi-definition", equalTo("test-openapi-definition"));
11291129
}
11301130

1131+
@Test(dataProvider = "formatProvider")
1132+
public void testWebhooks(String type) {
1133+
ValidatableResponse vr = callEndpoint(type);
1134+
1135+
String webhookPut = "webhooks.bookingEvent.put";
1136+
vr.body(webhookPut, notNullValue());
1137+
vr.body(webhookPut + ".summary", equalTo("Notifies that a booking has been created"));
1138+
vr.body(webhookPut + ".requestBody.content.'application/json'.schema.$ref",
1139+
equalTo("#/components/schemas/Booking"));
1140+
vr.body(webhookPut + ".responses.'204'.description",
1141+
equalTo("Indicates that the creation event was processed successfully"));
1142+
1143+
String webhookDelete = "webhooks.bookingEvent.delete";
1144+
vr.body(webhookPut, notNullValue());
1145+
vr.body(webhookDelete + ".summary", equalTo("Notifies that a booking has been deleted"));
1146+
vr.body(webhookDelete + ".requestBody.content.'application/json'.schema.$ref",
1147+
equalTo("#/components/schemas/Booking"));
1148+
vr.body(webhookDelete + ".responses.'204'.description",
1149+
equalTo("Indicates that the deletion event was processed successfully"));
1150+
1151+
vr.body("webhooks.bookingEvent.summary", equalTo("Booking Events"));
1152+
vr.body("webhooks.bookingEvent.description", equalTo("Notifies about booking creation and deletion"));
1153+
vr.body("webhooks.bookingEvent.x-webhook", equalTo("test-webhook"));
1154+
}
1155+
11311156
}

0 commit comments

Comments
 (0)