|
20 | 20 | import org.eclipse.microprofile.openapi.annotations.Components;
|
21 | 21 | import org.eclipse.microprofile.openapi.annotations.ExternalDocumentation;
|
22 | 22 | import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition;
|
| 23 | +import org.eclipse.microprofile.openapi.annotations.PathItem; |
| 24 | +import org.eclipse.microprofile.openapi.annotations.PathItemOperation; |
23 | 25 | import org.eclipse.microprofile.openapi.annotations.callbacks.Callback;
|
24 | 26 | import org.eclipse.microprofile.openapi.annotations.callbacks.CallbackOperation;
|
25 | 27 | import org.eclipse.microprofile.openapi.annotations.enums.ParameterIn;
|
|
60 | 62 | import jakarta.ws.rs.core.Application;
|
61 | 63 | import jakarta.ws.rs.core.MediaType;
|
62 | 64 |
|
| 65 | +@SuppressWarnings("checkstyle:linelength") // indentation of annotations leads to long lines |
63 | 66 | @ApplicationPath("/")
|
64 | 67 | @OpenAPIDefinition(
|
65 | 68 | tags = {@Tag(name = "user", description = "Operations about user"),
|
|
107 | 110 | extensions = @Extension(name = "x-server", value = "test-server")),
|
108 | 111 | @Server(url = "https://test-server.com:80/basePath", description = "The test API server")
|
109 | 112 | },
|
| 113 | + webhooks = { |
| 114 | + @PathItem(name = "bookingEvent", |
| 115 | + description = "Notifies about booking creation and deletion", |
| 116 | + summary = "Booking Events", |
| 117 | + operations = { |
| 118 | + @PathItemOperation(method = "put", |
| 119 | + summary = "Notifies that a booking has been created", |
| 120 | + requestBody = @RequestBody(content = @Content(mediaType = "application/json", |
| 121 | + schema = @Schema(ref = "#/components/schemas/Booking"))), |
| 122 | + responses = @APIResponse(responseCode = "204", |
| 123 | + description = "Indicates that the creation event was processed successfully")), |
| 124 | + @PathItemOperation(method = "delete", |
| 125 | + summary = "Notifies that a booking has been deleted", |
| 126 | + requestBody = @RequestBody(content = @Content(mediaType = "application/json", |
| 127 | + schema = @Schema(ref = "#/components/schemas/Booking"))), |
| 128 | + responses = @APIResponse(responseCode = "204", |
| 129 | + description = "Indicates that the deletion event was processed successfully")) |
| 130 | + }, |
| 131 | + extensions = @Extension(name = "x-webhook", value = "test-webhook")), |
| 132 | + @PathItem(name = "userEvent", ref = "UserEvent") |
| 133 | + }, |
110 | 134 | components = @Components(
|
111 | 135 | schemas = {
|
112 | 136 | @Schema(name = "Bookings", title = "Bookings",
|
|
219 | 243 | @APIResponse(ref = "FoundBookings")
|
220 | 244 | })),
|
221 | 245 | @Callback(name = "GetBookingsARef",
|
222 |
| - ref = "#/components/callbacks/GetBookings") |
| 246 | + ref = "#/components/callbacks/GetBookings"), |
| 247 | + @Callback(name = "UserEvents", |
| 248 | + callbackUrlExpression = "http://localhost:9080/users/events", |
| 249 | + pathItemRef = "UserEvent") |
| 250 | + }, |
| 251 | + pathItems = { |
| 252 | + @PathItem(name = "UserEvent", |
| 253 | + description = "Standard definition for receiving events about users", |
| 254 | + summary = "User Event reception API", |
| 255 | + operations = { |
| 256 | + @PathItemOperation( |
| 257 | + method = "PUT", |
| 258 | + summary = "User added event", |
| 259 | + description = "A user was added", |
| 260 | + externalDocs = @ExternalDocumentation(url = "http://example.com/docs"), |
| 261 | + operationId = "userAddedEvent", |
| 262 | + parameters = @Parameter(name = "authenticated", |
| 263 | + description = "Whether the user is authenticated", |
| 264 | + in = ParameterIn.QUERY, |
| 265 | + schema = @Schema(type = SchemaType.BOOLEAN), |
| 266 | + required = false), |
| 267 | + requestBody = @RequestBody( |
| 268 | + description = "The added user", |
| 269 | + content = @Content(mediaType = MediaType.APPLICATION_JSON, |
| 270 | + schema = @Schema(ref = "User"))), |
| 271 | + responses = { |
| 272 | + @APIResponse(responseCode = "200", |
| 273 | + description = "Event received"), |
| 274 | + @APIResponse(responseCode = "429", |
| 275 | + description = "Server is too busy to process the event. It will be sent again later") |
| 276 | + }), |
| 277 | + @PathItemOperation( |
| 278 | + method = "DELETE", |
| 279 | + summary = "A user was deleted", |
| 280 | + parameters = @Parameter(name = "id", |
| 281 | + in = ParameterIn.QUERY, |
| 282 | + schema = @Schema(type = SchemaType.STRING), |
| 283 | + required = true), |
| 284 | + responses = { |
| 285 | + @APIResponse(responseCode = "200", |
| 286 | + description = "Event received") |
| 287 | + }) |
| 288 | + }), |
| 289 | + @PathItem(name = "UserEventARef", |
| 290 | + ref = "#/components/pathItems/UserEvent", |
| 291 | + description = "UserEvent reference", |
| 292 | + summary = "Referenced PathItem"), |
| 293 | + @PathItem(name = "CallbackPathItem", |
| 294 | + operations = @PathItemOperation( |
| 295 | + method = "POST", |
| 296 | + responses = @APIResponse(responseCode = "200"), |
| 297 | + callbacks = @Callback(name = "getBookings", |
| 298 | + ref = "#/components/callbacks/GetBookings"))), |
| 299 | + // Test remaining properties on PathItemOperation |
| 300 | + @PathItem(name = "OperationTest", |
| 301 | + operations = @PathItemOperation( |
| 302 | + method = "POST", |
| 303 | + responses = @APIResponse(responseCode = "200"), |
| 304 | + deprecated = true, |
| 305 | + security = @SecurityRequirement(name = "testScheme1"), |
| 306 | + securitySets = @SecurityRequirementsSet({}), |
| 307 | + servers = @Server(url = "http://old.example.com/api"), |
| 308 | + extensions = @Extension(name = "x-operation", |
| 309 | + value = "test operation"))), |
| 310 | + // Test remaining properties on PathItem |
| 311 | + @PathItem(name = "PathItemTest", |
| 312 | + operations = { |
| 313 | + @PathItemOperation(method = "POST", |
| 314 | + responses = @APIResponse(responseCode = "200")), |
| 315 | + @PathItemOperation(method = "PUT", |
| 316 | + responses = @APIResponse(responseCode = "200")) |
| 317 | + }, |
| 318 | + servers = @Server(url = "http://example.com"), |
| 319 | + parameters = @Parameter(name = "id", |
| 320 | + in = ParameterIn.PATH, |
| 321 | + schema = @Schema(type = SchemaType.STRING)), |
| 322 | + extensions = @Extension(name = "x-pathItem", |
| 323 | + value = "test path item")) |
223 | 324 | },
|
224 | 325 | extensions = @Extension(name = "x-components", value = "test-components")),
|
225 | 326 | extensions = @Extension(name = "x-openapi-definition", value = "test-openapi-definition"))
|
|
0 commit comments