Add openapi annotations to the UserProfileResource
Closes https://github.com/keycloak/keycloak/issues/9318
This commit is contained in:
parent
d56baa80b3
commit
faf398e3c3
1 changed files with 15 additions and 6 deletions
|
@ -24,17 +24,22 @@ import java.util.Objects;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import jakarta.ws.rs.Path;
|
|
||||||
import org.eclipse.microprofile.openapi.annotations.Operation;
|
|
||||||
import jakarta.ws.rs.Consumes;
|
import jakarta.ws.rs.Consumes;
|
||||||
import jakarta.ws.rs.GET;
|
import jakarta.ws.rs.GET;
|
||||||
import jakarta.ws.rs.PUT;
|
import jakarta.ws.rs.PUT;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
|
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.media.Content;
|
||||||
|
import org.eclipse.microprofile.openapi.annotations.media.Schema;
|
||||||
|
import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody;
|
||||||
|
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.component.ComponentValidationException;
|
import org.keycloak.component.ComponentValidationException;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.RealmModel;
|
import org.keycloak.models.RealmModel;
|
||||||
|
@ -75,7 +80,8 @@ public class UserProfileResource {
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Tag(name = KeycloakOpenAPI.Admin.Tags.USERS)
|
@Tag(name = KeycloakOpenAPI.Admin.Tags.USERS)
|
||||||
@Operation()
|
@Operation(description = "Get the configuration for the user profile")
|
||||||
|
@APIResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = UPConfig.class)))
|
||||||
public String getConfiguration() {
|
public String getConfiguration() {
|
||||||
auth.requireAnyAdminRole();
|
auth.requireAnyAdminRole();
|
||||||
return session.getProvider(UserProfileProvider.class).getConfiguration();
|
return session.getProvider(UserProfileProvider.class).getConfiguration();
|
||||||
|
@ -85,7 +91,7 @@ public class UserProfileResource {
|
||||||
@Path("/metadata")
|
@Path("/metadata")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Tag(name = KeycloakOpenAPI.Admin.Tags.USERS)
|
@Tag(name = KeycloakOpenAPI.Admin.Tags.USERS)
|
||||||
@Operation()
|
@Operation(description = "Get the UserProfileMetadata from the configuration")
|
||||||
public UserProfileMetadata getMetadata() {
|
public UserProfileMetadata getMetadata() {
|
||||||
auth.requireAnyAdminRole();
|
auth.requireAnyAdminRole();
|
||||||
UserProfile profile = session.getProvider(UserProfileProvider.class).create(UserProfileContext.USER_API, Collections.emptyMap());
|
UserProfile profile = session.getProvider(UserProfileProvider.class).create(UserProfileContext.USER_API, Collections.emptyMap());
|
||||||
|
@ -94,9 +100,12 @@ public class UserProfileResource {
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Tag(name = KeycloakOpenAPI.Admin.Tags.USERS)
|
@Tag(name = KeycloakOpenAPI.Admin.Tags.USERS)
|
||||||
@Operation()
|
@Operation(description = "Set the configuration for the user profile")
|
||||||
public Response update(String text) {
|
@APIResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = UPConfig.class)))
|
||||||
|
public Response update(
|
||||||
|
@RequestBody(content = @Content(schema = @Schema(implementation = UPConfig.class))) String text) {
|
||||||
auth.realm().requireManageRealm();
|
auth.realm().requireManageRealm();
|
||||||
UserProfileProvider t = session.getProvider(UserProfileProvider.class);
|
UserProfileProvider t = session.getProvider(UserProfileProvider.class);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue