Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for requestBody in Operations which don't support a request body #616

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.eclipse.microprofile.openapi.annotations.security.SecurityScheme;

import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HEAD;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Response;
Expand All @@ -36,7 +38,29 @@ public class ZepplinResource {
@Operation(summary = "Deprecate outdated airship technology", operationId = "deprecateZepplin")
@Produces("text/plain")
@SecurityRequirement(name = "mutualTLSScheme", scopes = "zepplinScope")
public Response deprecateZepplin() {
public Response deprecateZepplin(String string) {
return Response.ok().build();
}

@HEAD
@Path("{id}")
@APIResponse(responseCode = "200", description = "Review deleted")
@APIResponse(responseCode = "404", description = "Review not found")
@Operation(summary = "Deprecate outdated airship technology", operationId = "deprecateZepplin")
@Produces("text/plain")
@SecurityRequirement(name = "mutualTLSScheme", scopes = "zepplinScope")
public Response headZepplin() {
return Response.ok().build();
}

@GET
@Path("{id}")
@APIResponse(responseCode = "200", description = "Review deleted")
@APIResponse(responseCode = "404", description = "Review not found")
@Operation(summary = "Deprecate outdated airship technology", operationId = "deprecateZepplin")
@Produces("text/plain")
@SecurityRequirement(name = "mutualTLSScheme", scopes = "zepplinScope")
public Response getZepplin() {
return Response.ok().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,19 @@ public OpenAPI buildModel() {
.description(
"Indicates that the deletion event was processed successfully")))))
.paths(OASFactory.createObject(Paths.class)
.addPathItem("/zepplins/{id}", OASFactory.createObject(PathItem.class)
.HEAD(OASFactory.createObject(Operation.class)
.requestBody(OASFactory.createRequestBody()
.ref("#/paths/~1zepplins~1{id}/delete/requestBody")))
.GET(OASFactory.createObject(Operation.class)
.requestBody(OASFactory.createRequestBody()
.ref("#/paths/~1zepplins~1{id}/delete/requestBody")))
.DELETE(OASFactory.createObject(Operation.class)
.requestBody(OASFactory.createRequestBody()
.description("Something about a zepplin.")
.content(OASFactory.createObject(Content.class)
.addMediaType("mediaType", OASFactory
.createObject(MediaType.class))))))
.addPathItem("/modelReader/airlines", OASFactory.createObject(PathItem.class)
.GET(OASFactory.createObject(Operation.class)
.summary("Retrieve all available airlines")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,15 @@ public void testWebhooks(String type) {
equalTo("Indicates that the deletion event was processed successfully"));

}

@Test(dataProvider = "formatProvider")
public void testRequestBodyInOperations(String type) {
ValidatableResponse vr = callEndpoint(type);

vr.body("paths.'/zepplins/{id}'.delete.requestBody.description", equalTo("Something about a zepplin."));
vr.body("paths.'/zepplins/{id}'.head.requestBody.$ref", equalTo("#/paths/~1zepplins~1{id}/delete/requestBody"));
vr.body("paths.'/zepplins/{id}'.get.requestBody.$ref", equalTo("#/paths/~1zepplins~1{id}/delete/requestBody"));

vr.body("paths.'/zepplins/{id}'.delete.requestBody.content", notNullValue());
}
}
Loading