Skip to content

Commit

Permalink
Add Webhook annotation TCK
Browse files Browse the repository at this point in the history
  • Loading branch information
Azquelt committed May 16, 2024
1 parent 0979161 commit 9488259
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

}

0 comments on commit 9488259

Please sign in to comment.