Skip to content

Commit

Permalink
EPMRPP-89661 || Several endpoint issues on API tab in "API Documentat…
Browse files Browse the repository at this point in the history
…ion"
  • Loading branch information
APiankouski authored Mar 4, 2024
2 parents beee517 + a34991b commit e9beba7
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
import io.swagger.v3.oas.models.tags.Tag;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
import javax.servlet.ServletContext;
import org.springdoc.core.SpringDocUtils;
import org.springdoc.core.customizers.OpenApiCustomiser;
import org.springdoc.core.customizers.OperationCustomizer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand All @@ -58,6 +60,7 @@ public class SpringDocConfiguration {
ReportPortalUser.class, UserRole.class);
SpringDocUtils.getConfig().replaceWithClass(org.springframework.data.domain.Pageable.class,
org.springdoc.core.converters.models.Pageable.class);
SpringDocUtils.getConfig().replaceWithClass(Iterable.class, List.class);
}

@Autowired
Expand Down Expand Up @@ -113,4 +116,21 @@ public OpenApiCustomiser sortTagsAlphabetically() {
openApi.setTags(sortedTags);
};
}

@Bean
public OperationCustomizer apiSummaryCustomizer() {
return (operation, handlerMethod) -> {
if (operation.getSummary() == null || operation.getSummary().isEmpty()) {
String methodName = handlerMethod.getMethod().getName();
String summary = convertMethodNameToTitle(methodName);
operation.setSummary(summary);
}
return operation;
};
}

private String convertMethodNameToTitle(String methodName) {
StringBuilder title = new StringBuilder(methodName.replaceAll("([A-Z])", " $1"));
return title.substring(0, 1).toUpperCase(Locale.ROOT) + title.substring(1).trim();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class CreateProjectRQ {
@Pattern(regexp = PROJECT_NAME_REGEXP)
@Size(min = ValidationConstraints.MIN_NAME_LENGTH, max = ValidationConstraints.MAX_NAME_LENGTH)
@JsonProperty(value = "projectName", required = true)
@Schema(requiredMode = RequiredMode.REQUIRED)
@Schema(requiredMode = RequiredMode.REQUIRED, example = "string")
private String projectName;

@NotBlank
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class CreateIssueSubTypeRQ {
@NotBlank
@Size(min = ValidationConstraints.MIN_SUBTYPE_SHORT_NAME, max = ValidationConstraints.MAX_SUBTYPE_SHORT_NAME)
@JsonProperty(value = "shortName", required = true)
@Schema(requiredMode = RequiredMode.REQUIRED)
@Schema(requiredMode = RequiredMode.REQUIRED, example = "string")
private String shortName;

@NotBlank
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class SenderCaseDTO implements Serializable {
@NotBlank
@JsonProperty(value = "sendCase")
@In(allowedValues = { "always", "failed", "toInvestigate", "more10", "more20", "more50" })
@Schema(allowableValues = "ALWAYS, FAILED, MORE_10, MORE_20, MORE_50")
@Schema(allowableValues = { "always", "failed", "toInvestigate", "more10", "more20", "more50" })
private String sendCase;

@NotBlankStringCollection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class CreateUserRQConfirm {
@Pattern(regexp = "[a-zA-Z0-9-_.]+")
@Size(min = ValidationConstraints.MIN_LOGIN_LENGTH, max = ValidationConstraints.MAX_LOGIN_LENGTH)
@JsonProperty(value = "login", required = true)
@Schema(requiredMode = RequiredMode.REQUIRED)
@Schema(requiredMode = RequiredMode.REQUIRED, example = "string")
private String login;

@NotBlank
Expand All @@ -51,7 +51,7 @@ public class CreateUserRQConfirm {
@Pattern(regexp = "[\\pL0-9-_ \\.]+")
@Size(min = ValidationConstraints.MIN_USER_NAME_LENGTH, max = ValidationConstraints.MAX_USER_NAME_LENGTH)
@JsonProperty(value = "fullName", required = true)
@Schema(requiredMode = RequiredMode.REQUIRED)
@Schema(requiredMode = RequiredMode.REQUIRED, example = "string")
private String fullName;

@NotBlank
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

Expand All @@ -46,6 +48,7 @@ public class EditUserRQ {
@Size(min = ValidationConstraints.MIN_USER_NAME_LENGTH, max = ValidationConstraints.MAX_USER_NAME_LENGTH)
@Pattern(regexp = "(\\s*[\\pL0-9-_\\.]+\\s*)+")
@JsonProperty(value = "fullName")
@Schema(requiredMode = RequiredMode.REQUIRED, example = "string")
private String fullName;

public String getEmail() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public ActivityController(ActivityHandler activityHandler, ProjectExtractor proj

@RequestMapping(value = "/{activityId}", method = RequestMethod.GET)
@ResponseStatus(OK)
@Operation(summary = "Get activity by id")
public ActivityResource getActivity(@PathVariable String projectName,
@PathVariable Long activityId, @AuthenticationPrincipal ReportPortalUser user) {
ReportPortalUser.ProjectDetails projectDetails =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public FileStorageController(ProjectExtractor projectExtractor, EditUserHandler
@Transactional(readOnly = true)
@PreAuthorize(ASSIGNED_TO_PROJECT)
@GetMapping(value = "/{projectName}/{dataId}")
@Operation(summary = "Get file")
public void getFile(@PathVariable String projectName, @PathVariable("dataId") Long dataId,
HttpServletResponse response,
@AuthenticationPrincipal ReportPortalUser user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
*/
@RestController
@RequestMapping("/v2/{projectName}/launch")
@Tag(name = "launch-async-controller", description = "Activity Controller")
@Tag(name = "launch-async-controller", description = "Launch Async Controller")
public class LaunchAsyncController {

private final ProjectExtractor projectExtractor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
import com.google.common.net.HttpHeaders;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.io.IOException;
Expand Down Expand Up @@ -457,9 +455,6 @@ public DeleteBulkRS deleteLaunches(@PathVariable String projectName,
);
}

@Parameters(
@Parameter(name = "launchImportRq", content = @Content(schema = @Schema(implementation = LaunchImportRQ.class)))
)
@PostMapping(value = "/import", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE })
@ResponseStatus(OK)
@Operation(summary = "Import junit xml report", description = "Only following formats are supported: zip and xml.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public ProjectResource getProject(@PathVariable String projectName,
@PutMapping("/{projectName}/unassign")
@ResponseStatus(OK)
@PreAuthorize(PROJECT_MANAGER)
@Operation(summary = "Un assign users")
@Operation(summary = "Unassign users")
public OperationCompletionRS unassignProjectUsers(@PathVariable String projectName,
@RequestBody @Validated UnassignUsersRQ unassignUsersRQ,
@AuthenticationPrincipal ReportPortalUser user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import com.epam.ta.reportportal.ws.resolver.FilterFor;
import com.epam.ta.reportportal.ws.resolver.SortFor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -233,6 +234,7 @@ public OperationCompletionRS handleSuggestChoose(@PathVariable String projectNam
@GetMapping
@ResponseStatus(OK)
@Operation(summary = "Find test items by specified filter")
@Schema(implementation = TestItemHistoryElement.class)
public Iterable<TestItemResource> getTestItems(@PathVariable String projectName,
@AuthenticationPrincipal ReportPortalUser user, @Nullable
@RequestParam(value = DEFAULT_FILTER_PREFIX + Condition.EQ + CRITERIA_LAUNCH_ID, required = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ public Iterable<UserResource> getUsers(@FilterFor(User.class) Filter filter,

@Transactional(readOnly = true)
@GetMapping(value = "/registration/info")

public YesNoRS validateInfo(@RequestParam(value = "username", required = false) String username,
@RequestParam(value = "email", required = false) String email) {
return getUserHandler.validateInfo(username, email);
Expand Down

0 comments on commit e9beba7

Please sign in to comment.