diff --git a/tck/src/main/java/org/eclipse/microprofile/openapi/apps/airlines/JAXRSApp.java b/tck/src/main/java/org/eclipse/microprofile/openapi/apps/airlines/JAXRSApp.java index 50d6aae1..c4406a10 100644 --- a/tck/src/main/java/org/eclipse/microprofile/openapi/apps/airlines/JAXRSApp.java +++ b/tck/src/main/java/org/eclipse/microprofile/openapi/apps/airlines/JAXRSApp.java @@ -22,6 +22,7 @@ import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition; import org.eclipse.microprofile.openapi.annotations.callbacks.Callback; import org.eclipse.microprofile.openapi.annotations.callbacks.CallbackOperation; +import org.eclipse.microprofile.openapi.annotations.callbacks.Webhook; import org.eclipse.microprofile.openapi.annotations.enums.ParameterIn; import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; import org.eclipse.microprofile.openapi.annotations.enums.SecuritySchemeIn; @@ -107,6 +108,26 @@ extensions = @Extension(name = "x-server", value = "test-server")), @Server(url = "https://test-server.com:80/basePath", description = "The test API server") }, + webhooks = { + @Webhook(name = "bookingEvent", + description = "Notifies about booking creation and deletion", + summary = "Booking Events", + operations = { + @CallbackOperation(method = "put", + summary = "Notifies that a booking has been created", + requestBody = @RequestBody(content = @Content(mediaType = "application/json", + schema = @Schema(ref = "#/components/schemas/Booking"))), + responses = @APIResponse(responseCode = "204", + description = "Indicates that the creation event was processed successfully")), + @CallbackOperation(method = "delete", + summary = "Notifies that a booking has been deleted", + requestBody = @RequestBody(content = @Content(mediaType = "application/json", + schema = @Schema(ref = "#/components/schemas/Booking"))), + responses = @APIResponse(responseCode = "204", + description = "Indicates that the deletion event was processed successfully")) + }, + extensions = @Extension(name = "x-webhook", value = "test-webhook")) + }, components = @Components( schemas = { @Schema(name = "Bookings", title = "Bookings", diff --git a/tck/src/main/java/org/eclipse/microprofile/openapi/tck/AirlinesAppTest.java b/tck/src/main/java/org/eclipse/microprofile/openapi/tck/AirlinesAppTest.java index b83d3bb2..e05a163c 100644 --- a/tck/src/main/java/org/eclipse/microprofile/openapi/tck/AirlinesAppTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/openapi/tck/AirlinesAppTest.java @@ -1128,4 +1128,29 @@ public void testOpenAPIDefinitionExtension(String type) { vr.body("x-openapi-definition", equalTo("test-openapi-definition")); } + @Test(dataProvider = "formatProvider") + public void testWebhooks(String type) { + ValidatableResponse vr = callEndpoint(type); + + String webhookPut = "webhooks.bookingEvent.put"; + vr.body(webhookPut, notNullValue()); + vr.body(webhookPut + ".summary", equalTo("Notifies that a booking has been created")); + vr.body(webhookPut + ".requestBody.content.'application/json'.schema.$ref", + equalTo("#/components/schemas/Booking")); + vr.body(webhookPut + ".responses.'204'.description", + equalTo("Indicates that the creation event was processed successfully")); + + String webhookDelete = "webhooks.bookingEvent.delete"; + vr.body(webhookPut, notNullValue()); + vr.body(webhookDelete + ".summary", equalTo("Notifies that a booking has been deleted")); + vr.body(webhookDelete + ".requestBody.content.'application/json'.schema.$ref", + equalTo("#/components/schemas/Booking")); + vr.body(webhookDelete + ".responses.'204'.description", + equalTo("Indicates that the deletion event was processed successfully")); + + vr.body("webhooks.bookingEvent.summary", equalTo("Booking Events")); + vr.body("webhooks.bookingEvent.description", equalTo("Notifies about booking creation and deletion")); + vr.body("webhooks.bookingEvent.x-webhook", equalTo("test-webhook")); + } + }