Add correct annotation for 204 responses to POST methods returning void

Closes #24960

Signed-off-by: Sophie Tauchert <sophie@999eagle.moe>
This commit is contained in:
Sophie Tauchert 2023-11-10 14:16:04 +01:00 committed by Alexander Schwartz
parent efde3adf60
commit 3e17cb0452
11 changed files with 29 additions and 0 deletions

View file

@ -19,6 +19,7 @@ package org.keycloak.services.resources.admin;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.annotations.cache.NoCache;
@ -840,6 +841,7 @@ public class AuthenticationManagementResource {
@NoCache @NoCache
@Tag(name = KeycloakOpenAPI.Admin.Tags.AUTHENTICATION_MANAGEMENT) @Tag(name = KeycloakOpenAPI.Admin.Tags.AUTHENTICATION_MANAGEMENT)
@Operation( summary = "Raise execution's priority") @Operation( summary = "Raise execution's priority")
@APIResponse(responseCode = "204", description = "No Content")
public void raisePriority(@Parameter(description = "Execution id") @PathParam("executionId") String execution) { public void raisePriority(@Parameter(description = "Execution id") @PathParam("executionId") String execution) {
auth.realm().requireManageRealm(); auth.realm().requireManageRealm();
@ -882,6 +884,7 @@ public class AuthenticationManagementResource {
@NoCache @NoCache
@Tag(name = KeycloakOpenAPI.Admin.Tags.AUTHENTICATION_MANAGEMENT) @Tag(name = KeycloakOpenAPI.Admin.Tags.AUTHENTICATION_MANAGEMENT)
@Operation( summary = "Lower execution's priority") @Operation( summary = "Lower execution's priority")
@APIResponse(responseCode = "204", description = "No Content")
public void lowerPriority(@Parameter( description = "Execution id") @PathParam("executionId") String execution) { public void lowerPriority(@Parameter( description = "Execution id") @PathParam("executionId") String execution) {
auth.realm().requireManageRealm(); auth.realm().requireManageRealm();
@ -1049,6 +1052,7 @@ public class AuthenticationManagementResource {
@NoCache @NoCache
@Tag(name = KeycloakOpenAPI.Admin.Tags.AUTHENTICATION_MANAGEMENT) @Tag(name = KeycloakOpenAPI.Admin.Tags.AUTHENTICATION_MANAGEMENT)
@Operation( summary = "Register a new required actions") @Operation( summary = "Register a new required actions")
@APIResponse(responseCode = "204", description = "No Content")
public void registerRequiredAction(@Parameter(description = "JSON containing 'providerId', and 'name' attributes.") Map<String, String> data) { public void registerRequiredAction(@Parameter(description = "JSON containing 'providerId', and 'name' attributes.") Map<String, String> data) {
auth.realm().requireManageRealm(); auth.realm().requireManageRealm();
@ -1185,6 +1189,7 @@ public class AuthenticationManagementResource {
@NoCache @NoCache
@Tag(name = KeycloakOpenAPI.Admin.Tags.AUTHENTICATION_MANAGEMENT) @Tag(name = KeycloakOpenAPI.Admin.Tags.AUTHENTICATION_MANAGEMENT)
@Operation( summary = "Raise required action's priority") @Operation( summary = "Raise required action's priority")
@APIResponse(responseCode = "204", description = "No Content")
public void raiseRequiredActionPriority(@Parameter(description = "Alias of required action") @PathParam("alias") String alias) { public void raiseRequiredActionPriority(@Parameter(description = "Alias of required action") @PathParam("alias") String alias) {
auth.realm().requireManageRealm(); auth.realm().requireManageRealm();
@ -1220,6 +1225,7 @@ public class AuthenticationManagementResource {
@NoCache @NoCache
@Tag(name = KeycloakOpenAPI.Admin.Tags.AUTHENTICATION_MANAGEMENT) @Tag(name = KeycloakOpenAPI.Admin.Tags.AUTHENTICATION_MANAGEMENT)
@Operation( summary = "Lower required action's priority") @Operation( summary = "Lower required action's priority")
@APIResponse(responseCode = "204", description = "No Content")
public void lowerRequiredActionPriority(@Parameter(description = "Alias of required action") @PathParam("alias") String alias) { public void lowerRequiredActionPriority(@Parameter(description = "Alias of required action") @PathParam("alias") String alias) {
auth.realm().requireManageRealm(); auth.realm().requireManageRealm();

View file

@ -19,6 +19,7 @@ package org.keycloak.services.resources.admin;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import jakarta.ws.rs.core.Response.Status; import jakarta.ws.rs.core.Response.Status;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
@ -621,6 +622,7 @@ public class ClientResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.CLIENTS) @Tag(name = KeycloakOpenAPI.Admin.Tags.CLIENTS)
@Operation( summary = "Register a cluster node with the client Manually register cluster node to this client - usually its not needed to call this directly as adapter should handle by sending registration request to Keycloak") @Operation( summary = "Register a cluster node with the client Manually register cluster node to this client - usually its not needed to call this directly as adapter should handle by sending registration request to Keycloak")
@APIResponse(responseCode = "204", description = "No Content")
public void registerNode(Map<String, String> formParams) { public void registerNode(Map<String, String> formParams) {
auth.clients().requireConfigure(client); auth.clients().requireConfigure(client);

View file

@ -19,6 +19,7 @@ package org.keycloak.services.resources.admin;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.annotations.cache.NoCache;
@ -159,6 +160,7 @@ public class ClientRoleMappingsResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.CLIENT_ROLE_MAPPINGS) @Tag(name = KeycloakOpenAPI.Admin.Tags.CLIENT_ROLE_MAPPINGS)
@Operation( summary = "Add client-level roles to the user role mapping") @Operation( summary = "Add client-level roles to the user role mapping")
@APIResponse(responseCode = "204", description = "No Content")
public void addClientRoleMapping(List<RoleRepresentation> roles) { public void addClientRoleMapping(List<RoleRepresentation> roles) {
managePermission.require(); managePermission.require();

View file

@ -21,6 +21,7 @@ import static org.keycloak.protocol.ProtocolMapperUtils.isEnabled;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.annotations.cache.NoCache;
@ -152,6 +153,7 @@ public class ProtocolMappersResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.PROTOCOL_MAPPERS) @Tag(name = KeycloakOpenAPI.Admin.Tags.PROTOCOL_MAPPERS)
@Operation(summary = "Create multiple mappers") @Operation(summary = "Create multiple mappers")
@APIResponse(responseCode = "204", description = "No Content")
public void createMapper(List<ProtocolMapperRepresentation> reps) { public void createMapper(List<ProtocolMapperRepresentation> reps) {
managePermission.require(); managePermission.require();

View file

@ -21,6 +21,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.keycloak.http.FormPartValue; import org.keycloak.http.FormPartValue;
import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSession;
@ -92,6 +93,7 @@ public class RealmLocalizationResource {
@Consumes(MediaType.MULTIPART_FORM_DATA) @Consumes(MediaType.MULTIPART_FORM_DATA)
@Tag(name = KeycloakOpenAPI.Admin.Tags.REALMS_ADMIN) @Tag(name = KeycloakOpenAPI.Admin.Tags.REALMS_ADMIN)
@Operation( summary = "Import localization from uploaded JSON file") @Operation( summary = "Import localization from uploaded JSON file")
@APIResponse(responseCode = "204", description = "No Content")
public void createOrUpdateRealmLocalizationTextsFromFile(@PathParam("locale") String locale) { public void createOrUpdateRealmLocalizationTextsFromFile(@PathParam("locale") String locale) {
this.auth.realm().requireManageRealm(); this.auth.realm().requireManageRealm();
@ -114,6 +116,7 @@ public class RealmLocalizationResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.REALMS_ADMIN) @Tag(name = KeycloakOpenAPI.Admin.Tags.REALMS_ADMIN)
@Operation() @Operation()
@APIResponse(responseCode = "204", description = "No Content")
public void createOrUpdateRealmLocalizationTexts(@PathParam("locale") String locale, public void createOrUpdateRealmLocalizationTexts(@PathParam("locale") String locale,
Map<String, String> localizationTexts) { Map<String, String> localizationTexts) {
this.auth.realm().requireManageRealm(); this.auth.realm().requireManageRealm();

View file

@ -19,6 +19,7 @@ package org.keycloak.services.resources.admin;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.annotations.cache.NoCache;
@ -171,6 +172,7 @@ public class RoleByIdResource extends RoleResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.ROLES_BY_ID) @Tag(name = KeycloakOpenAPI.Admin.Tags.ROLES_BY_ID)
@Operation( summary = "Make the role a composite role by associating some child roles") @Operation( summary = "Make the role a composite role by associating some child roles")
@APIResponse(responseCode = "204", description = "No Content")
public void addComposites(final @PathParam("role-id") String id, List<RoleRepresentation> roles) { public void addComposites(final @PathParam("role-id") String id, List<RoleRepresentation> roles) {
RoleModel role = getRoleModel(id); RoleModel role = getRoleModel(id);
auth.roles().requireManage(role); auth.roles().requireManage(role);

View file

@ -20,6 +20,7 @@ package org.keycloak.services.resources.admin;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.annotations.cache.NoCache;
import jakarta.ws.rs.NotFoundException; import jakarta.ws.rs.NotFoundException;
@ -312,6 +313,7 @@ public class RoleContainerResource extends RoleResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.ROLES) @Tag(name = KeycloakOpenAPI.Admin.Tags.ROLES)
@Operation( summary = "Add a composite to the role") @Operation( summary = "Add a composite to the role")
@APIResponse(responseCode = "204", description = "No Content")
public void addComposites(final @Parameter(description = "role's name (not id!)") @PathParam("role-name") String roleName, List<RoleRepresentation> roles) { public void addComposites(final @Parameter(description = "role's name (not id!)") @PathParam("role-name") String roleName, List<RoleRepresentation> roles) {
auth.roles().requireManage(roleContainer); auth.roles().requireManage(roleContainer);
RoleModel role = roleContainer.getRole(roleName); RoleModel role = roleContainer.getRole(roleName);

View file

@ -19,6 +19,7 @@ package org.keycloak.services.resources.admin;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.annotations.cache.NoCache;
@ -227,6 +228,7 @@ public class RoleMapperResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.ROLE_MAPPER) @Tag(name = KeycloakOpenAPI.Admin.Tags.ROLE_MAPPER)
@Operation( summary = "Add realm-level role mappings to the user") @Operation( summary = "Add realm-level role mappings to the user")
@APIResponse(responseCode = "204", description = "No Content")
public void addRealmRoleMappings(@Parameter(description = "Roles to add") List<RoleRepresentation> roles) { public void addRealmRoleMappings(@Parameter(description = "Roles to add") List<RoleRepresentation> roles) {
managePermission.require(); managePermission.require();

View file

@ -20,6 +20,7 @@ package org.keycloak.services.resources.admin;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.annotations.cache.NoCache;
import jakarta.ws.rs.NotFoundException; import jakarta.ws.rs.NotFoundException;
@ -155,6 +156,7 @@ public class ScopeMappedClientResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.SCOPE_MAPPINGS) @Tag(name = KeycloakOpenAPI.Admin.Tags.SCOPE_MAPPINGS)
@Operation(summary = "Add client-level roles to the client's scope") @Operation(summary = "Add client-level roles to the client's scope")
@APIResponse(responseCode = "204", description = "No Content")
public void addClientScopeMapping(List<RoleRepresentation> roles) { public void addClientScopeMapping(List<RoleRepresentation> roles) {
managePermission.require(); managePermission.require();

View file

@ -20,6 +20,7 @@ package org.keycloak.services.resources.admin;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.annotations.cache.NoCache;
import jakarta.ws.rs.NotFoundException; import jakarta.ws.rs.NotFoundException;
@ -214,6 +215,7 @@ public class ScopeMappedResource {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.SCOPE_MAPPINGS) @Tag(name = KeycloakOpenAPI.Admin.Tags.SCOPE_MAPPINGS)
@Operation(summary = "Add a set of realm-level roles to the client's scope") @Operation(summary = "Add a set of realm-level roles to the client's scope")
@APIResponse(responseCode = "204", description = "No Content")
public void addRealmScopeMappings(List<RoleRepresentation> roles) { public void addRealmScopeMappings(List<RoleRepresentation> roles) {
managePermission.require(); managePermission.require();

View file

@ -19,6 +19,7 @@ package org.keycloak.services.resources.admin;
import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension; import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter; import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.tags.Tag; import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.jboss.resteasy.annotations.cache.NoCache; import org.jboss.resteasy.annotations.cache.NoCache;
@ -605,6 +606,7 @@ public class UserResource {
@POST @POST
@Tag(name = KeycloakOpenAPI.Admin.Tags.USERS) @Tag(name = KeycloakOpenAPI.Admin.Tags.USERS)
@Operation( summary = "Remove all user sessions associated with the user Also send notification to all clients that have an admin URL to invalidate the sessions for the particular user.") @Operation( summary = "Remove all user sessions associated with the user Also send notification to all clients that have an admin URL to invalidate the sessions for the particular user.")
@APIResponse(responseCode = "204", description = "No Content")
public void logout() { public void logout() {
auth.users().requireManage(user); auth.users().requireManage(user);
@ -787,6 +789,7 @@ public class UserResource {
@POST @POST
@Tag(name = KeycloakOpenAPI.Admin.Tags.USERS) @Tag(name = KeycloakOpenAPI.Admin.Tags.USERS)
@Operation( summary = "Move a credential to a first position in the credentials list of the user") @Operation( summary = "Move a credential to a first position in the credentials list of the user")
@APIResponse(responseCode = "204", description = "No Content")
public void moveCredentialToFirst(final @Parameter(description = "The credential to move") @PathParam("credentialId") String credentialId){ public void moveCredentialToFirst(final @Parameter(description = "The credential to move") @PathParam("credentialId") String credentialId){
moveCredentialAfter(credentialId, null); moveCredentialAfter(credentialId, null);
} }
@ -800,6 +803,7 @@ public class UserResource {
@POST @POST
@Tag(name = KeycloakOpenAPI.Admin.Tags.USERS) @Tag(name = KeycloakOpenAPI.Admin.Tags.USERS)
@Operation( summary = "Move a credential to a position behind another credential") @Operation( summary = "Move a credential to a position behind another credential")
@APIResponse(responseCode = "204", description = "No Content")
public void moveCredentialAfter(final @Parameter(description = "The credential to move") @PathParam("credentialId") String credentialId, public void moveCredentialAfter(final @Parameter(description = "The credential to move") @PathParam("credentialId") String credentialId,
final @Parameter(description = "The credential that will be the previous element in the list. If set to null, the moved credential will be the first element in the list.") @PathParam("newPreviousCredentialId") String newPreviousCredentialId){ final @Parameter(description = "The credential that will be the previous element in the list. If set to null, the moved credential will be the first element in the list.") @PathParam("newPreviousCredentialId") String newPreviousCredentialId){
auth.users().requireManage(user); auth.users().requireManage(user);