Skip to content

Commit

Permalink
Use Tag annotation in PathItemOperation
Browse files Browse the repository at this point in the history
Use nested Tag annotations in PathItemOperation for consistency with the
way Tags can be defined for other operations.
  • Loading branch information
Azquelt committed Jun 7, 2024
1 parent 65919a6 commit 81281df
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement;
import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirementsSet;
import org.eclipse.microprofile.openapi.annotations.servers.Server;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;

/**
* Describes an Operation
Expand All @@ -48,11 +49,11 @@
String method();

/**
* The tag names which apply to this operation.
* The tags which apply to this operation.
*
* @return the list of tag names
* @return the list of tags
*/
String[] tags() default {}; // Could be @Tag[]
Tag[] tags() default {};

/**
* Provides a brief description of what this operation does.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@
method = "POST",
responses = @APIResponse(responseCode = "200"),
deprecated = true,
tags = {
@Tag(ref = "create"),
@Tag(name = "pathItemTest",
description = "part of the path item tests")
},
security = @SecurityRequirement(name = "testScheme1"),
securitySets = @SecurityRequirementsSet({}),
servers = @Server(url = "http://old.example.com/api"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,7 @@ public void testPathItemOperation(String type) {

op = "components.pathItems.OperationTest.post";
vr.body(op, notNullValue());
vr.body(op + ".tags", containsInAnyOrder("create", "pathItemTest"));
vr.body(op + ".deprecated", equalTo(true));
vr.body(op + ".security", hasSize(2));
vr.body(op + ".security", hasItem(anEmptyMap()));
Expand All @@ -1243,6 +1244,9 @@ public void testPathItemOperation(String type) {
vr.body(op + ".security.testScheme1", containsInAnyOrder(emptyIterable(), nullValue()));
vr.body(op + ".servers[0].url", equalTo("http://old.example.com/api"));
vr.body(op + ".x-operation", equalTo("test operation"));

// Check the new tag was created
vr.body("tags.findAll { it.name == 'pathItemTest'}.description", contains("part of the path item tests"));
}

@Test(dataProvider = "formatProvider")
Expand Down

0 comments on commit 81281df

Please sign in to comment.