aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAurelien Poscia <aurelien.poscia@sonarsource.com>2023-08-16 14:21:04 +0200
committersonartech <sonartech@sonarsource.com>2023-08-18 20:02:50 +0000
commit73150fa76e4ec39a30560391487a3b194d6cea6d (patch)
tree576c40d953f09a91f66642f4f523d37c2ba151a2 /server
parent2e6289d6bc22fcdae70d7cbcf6d7cba546c49a46 (diff)
downloadsonarqube-73150fa76e4ec39a30560391487a3b194d6cea6d.tar.gz
sonarqube-73150fa76e4ec39a30560391487a3b194d6cea6d.zip
SONAR-20181 Rename api/v2 pageRestResponse to page and improve doc
Diffstat (limited to 'server')
-rw-r--r--server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/model/RestPage.java9
-rw-r--r--server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/controller/UserController.java12
-rw-r--r--server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/request/UsersSearchRestRequest.java17
-rw-r--r--server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/response/UsersSearchRestResponse.java2
-rw-r--r--server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/user/controller/DefaultUserControllerTest.java2
-rw-r--r--server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/user/converter/UsersSearchRestResponseGeneratorTest.java8
6 files changed, 23 insertions, 27 deletions
diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/model/RestPage.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/model/RestPage.java
index 8336a2385b9..6a1141c2861 100644
--- a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/model/RestPage.java
+++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/model/RestPage.java
@@ -20,7 +20,6 @@
package org.sonar.server.v2.api.model;
import com.google.common.annotations.VisibleForTesting;
-import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
@@ -30,15 +29,11 @@ import org.jetbrains.annotations.Nullable;
public record RestPage(
@Min(1)
@Max(500)
- @Parameter(
- description = "Number of results per page",
- schema = @Schema(defaultValue = DEFAULT_PAGE_SIZE, implementation = Integer.class))
+ @Schema(defaultValue = DEFAULT_PAGE_SIZE, description = "Number of results per page")
Integer pageSize,
@Positive
- @Parameter(
- description = "1-based page number",
- schema = @Schema(defaultValue = DEFAULT_PAGE_INDEX, implementation = Integer.class))
+ @Schema(defaultValue = DEFAULT_PAGE_INDEX, description = "Number of results per page")
Integer pageIndex
) {
diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/controller/UserController.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/controller/UserController.java
index 2e9087fc331..e0271e896ee 100644
--- a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/controller/UserController.java
+++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/controller/UserController.java
@@ -65,10 +65,14 @@ public interface UserController {
@DeleteMapping(path = "/{login}")
@ResponseStatus(HttpStatus.NO_CONTENT)
- @Operation(summary = "Deactivate a user", description = "Deactivate a user. Requires Administer System permission.")
+ @Operation(summary = "Deactivate a user", description = "Deactivates a user. Requires Administer System permission.")
void deactivate(
- @PathVariable("login") @Parameter(description = "The login of the user to delete.", required = true, in = ParameterIn.PATH) String login,
- @RequestParam(value = "anonymize", required = false, defaultValue = "false") @Parameter(description = "Anonymize user in addition to deactivating it.") Boolean anonymize);
+ @PathVariable("login")
+ @Parameter(description = "The login of the user to delete.", required = true, in = ParameterIn.PATH)
+ String login,
+ @RequestParam(value = "anonymize", required = false, defaultValue = "false")
+ @Parameter(description = "Anonymize user in addition to deactivating it.")
+ Boolean anonymize);
@GetMapping(path = "/{login}")
@ResponseStatus(HttpStatus.OK)
@@ -93,6 +97,6 @@ public interface UserController {
If a deactivated user account exists with the given login, it will be reactivated.
Requires Administer System permission
""")
- RestUser create(@Valid @RequestBody(required = true) UserCreateRestRequest userCreateRestRequest);
+ RestUser create(@Valid @RequestBody UserCreateRestRequest userCreateRestRequest);
}
diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/request/UsersSearchRestRequest.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/request/UsersSearchRestRequest.java
index 318424c8a85..7c372ee2fb7 100644
--- a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/request/UsersSearchRestRequest.java
+++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/request/UsersSearchRestRequest.java
@@ -19,39 +19,36 @@
*/
package org.sonar.server.v2.api.user.request;
-import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.annotation.Nullable;
public record UsersSearchRestRequest(
- @Parameter(
- description = "Return active/inactive users",
- schema = @Schema(defaultValue = "true", implementation = Boolean.class))
+ @Schema(defaultValue = "true", description = "Return active/inactive users")
Boolean active,
@Nullable
- @Parameter(description = "Return managed or non-managed users. Only available for managed instances, throws for non-managed instances")
+ @Schema(description = "Return managed or non-managed users. Only available for managed instances, throws for non-managed instances")
Boolean managed,
@Nullable
- @Parameter(description = "Filter on login, name and email.\n"
+ @Schema(description = "Filter on login, name and email.\n"
+ "This parameter can either perform an exact match, or a partial match (contains), it is case insensitive.")
String q,
@Nullable
- @Parameter(description = "Filter the users based on the last connection date field. Only users who interacted with this instance at or after the date will be returned. "
+ @Schema(description = "Filter the users based on the last connection date field. Only users who interacted with this instance at or after the date will be returned. "
+ "The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)",
example = "2020-01-01T00:00:00+0100")
String sonarQubeLastConnectionDateFrom,
@Nullable
- @Parameter(description = "Filter the users based on the last connection date field. Only users that never connected or who interacted with this instance at "
+ @Schema(description = "Filter the users based on the last connection date field. Only users that never connected or who interacted with this instance at "
+ "or before the date will be returned. The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)",
example = "2020-01-01T00:00:00+0100")
String sonarQubeLastConnectionDateTo,
@Nullable
- @Parameter(description = "Filter the users based on the sonar lint last connection date field Only users who interacted with this instance using SonarLint at or after "
+ @Schema(description = "Filter the users based on the sonar lint last connection date field Only users who interacted with this instance using SonarLint at or after "
+ "the date will be returned. The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)",
example = "2020-01-01T00:00:00+0100")
String sonarLintLastConnectionDateFrom,
@Nullable
- @Parameter(description = "Filter the users based on the sonar lint last connection date field. Only users that never connected or who interacted with this instance "
+ @Schema(description = "Filter the users based on the sonar lint last connection date field. Only users that never connected or who interacted with this instance "
+ "using SonarLint at or before the date will be returned. The format must be ISO 8601 datetime format (YYYY-MM-DDThh:mm:ss±hhmm)",
example = "2020-01-01T00:00:00+0100")
String sonarLintLastConnectionDateTo
diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/response/UsersSearchRestResponse.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/response/UsersSearchRestResponse.java
index 38e5a2dd897..9ef72a477d5 100644
--- a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/response/UsersSearchRestResponse.java
+++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/user/response/UsersSearchRestResponse.java
@@ -23,5 +23,5 @@ import java.util.List;
import org.sonar.server.v2.api.response.PageRestResponse;
import org.sonar.server.v2.api.user.model.RestUser;
-public record UsersSearchRestResponse(List<RestUser> users, PageRestResponse pageRestResponse) {
+public record UsersSearchRestResponse(List<RestUser> users, PageRestResponse page) {
}
diff --git a/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/user/controller/DefaultUserControllerTest.java b/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/user/controller/DefaultUserControllerTest.java
index 8f42313d813..bcfdd4be4fd 100644
--- a/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/user/controller/DefaultUserControllerTest.java
+++ b/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/user/controller/DefaultUserControllerTest.java
@@ -157,7 +157,7 @@ public class DefaultUserControllerTest {
UsersSearchRestResponse actualUsersSearchRestResponse = gson.fromJson(mvcResult.getResponse().getContentAsString(), UsersSearchRestResponse.class);
assertThat(actualUsersSearchRestResponse.users())
.containsExactlyElementsOf(restUsers);
- assertThat(actualUsersSearchRestResponse.pageRestResponse().total()).isEqualTo(users.size());
+ assertThat(actualUsersSearchRestResponse.page().total()).isEqualTo(users.size());
}
diff --git a/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/user/converter/UsersSearchRestResponseGeneratorTest.java b/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/user/converter/UsersSearchRestResponseGeneratorTest.java
index 17ac7aeec51..e33ed4283cf 100644
--- a/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/user/converter/UsersSearchRestResponseGeneratorTest.java
+++ b/server/sonar-webserver-webapi-v2/src/test/java/org/sonar/server/v2/api/user/converter/UsersSearchRestResponseGeneratorTest.java
@@ -57,7 +57,7 @@ public class UsersSearchRestResponseGeneratorTest {
UsersSearchRestResponse usersForResponse = usersSearchRestResponseGenerator.toUsersForResponse(List.of(), paging);
assertThat(usersForResponse.users()).isEmpty();
- assertPaginationInformationAreCorrect(paging, usersForResponse.pageRestResponse());
+ assertPaginationInformationAreCorrect(paging, usersForResponse.page());
}
@Test
@@ -75,7 +75,7 @@ public class UsersSearchRestResponseGeneratorTest {
RestUser expectUser1 = buildExpectedResponseForAdmin(userSearchResult1);
RestUser expectUser2 = buildExpectedResponseForAdmin(userSearchResult2);
assertThat(usersForResponse.users()).containsExactly(expectUser1, expectUser2);
- assertPaginationInformationAreCorrect(paging, usersForResponse.pageRestResponse());
+ assertPaginationInformationAreCorrect(paging, usersForResponse.page());
}
private static RestUser buildExpectedResponseForAdmin(UserSearchResult userSearchResult) {
@@ -113,7 +113,7 @@ public class UsersSearchRestResponseGeneratorTest {
RestUser expectUser1 = buildExpectedResponseForUser(userSearchResult1);
RestUser expectUser2 = buildExpectedResponseForUser(userSearchResult2);
assertThat(usersForResponse.users()).containsExactly(expectUser1, expectUser2);
- assertPaginationInformationAreCorrect(paging, usersForResponse.pageRestResponse());
+ assertPaginationInformationAreCorrect(paging, usersForResponse.page());
}
private static RestUser buildExpectedResponseForUser(UserSearchResult userSearchResult) {
@@ -149,7 +149,7 @@ public class UsersSearchRestResponseGeneratorTest {
RestUser expectUser1 = buildExpectedResponseForAnonymous(userSearchResult1);
RestUser expectUser2 = buildExpectedResponseForAnonymous(userSearchResult2);
assertThat(usersForResponse.users()).containsExactly(expectUser1, expectUser2);
- assertPaginationInformationAreCorrect(paging, usersForResponse.pageRestResponse());
+ assertPaginationInformationAreCorrect(paging, usersForResponse.page());
}
private static RestUser buildExpectedResponseForAnonymous(UserSearchResult userSearchResult) {