RolesRepresentation should be used as type for roles in RealmRepresentation
vidi42 opened this issue · 1 comments
vidi42 commented
Describe the bug
As defined in the REST API documentation the RealmRepresentation.roles
field should be of type RolesRepresentation supporting multiple roles.
However, the roles
field is wrongly declared with the type RoleRepresentation which is just for a single role.
Expected behavior
- new definition for RolesRepresentation
- RealmRepresentation
.roles
should use the new definition
vidi42 commented
A workaround for this is to declare a new CustomRealmRepresentation
type which replaces the type of roles
to a custom type.
export type CustomRealmRepresentation = Omit<RealmRepresentation, 'roles'> & { roles: { realm: { name: string }[] } };
//you can create your own RolesRepresentation according to https://www.keycloak.org/docs-api/10.0/rest-api/index.html#_rolesrepresentation and use that to define the roles
Then use the new makeRequest
method to create a realm using the new type
const realmRepresentation : CustomRealmRepresentation = newRealmRepresentation();
const createRequest = await keycloakClient.realms.makeRequest({ method: 'POST', returnResourceIdInLocationHeader: { field: 'realmName' } });
createRequest(realmRepresentation);