Skip to content

Commit

Permalink
Added operation info for InternalInviteController#deleteRole
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Nov 6, 2024
1 parent 819c9fb commit 45e45fb
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
Expand Down Expand Up @@ -234,6 +235,38 @@ public ResponseEntity<Role> updateRole(@Validated @RequestBody Role role,

@DeleteMapping("/roles/{id}")
@PreAuthorize("hasRole('SP_DASHBOARD')")
@Operation(summary = "Delete existing Role",
description = "Delete an existing role. The path parameter id is the id returned when creating the role.",
parameters = {@Parameter(name = "id", in = ParameterIn.PATH, description = "Unique database id of the role", required = true)},
responses = {
@ApiResponse(responseCode = "204", description = "No content"),
@ApiResponse(responseCode = "400", description = "BadRequest",
content = {@Content(schema = @Schema(implementation = StatusResponse.class),
examples = {@ExampleObject(value = """
{
"timestamp": 1717672263253,
"status": 400,
"error": "BadRequest",
"exception": "access.exception.UserRestrictionException",
"message": "No access to role",
"path": "/api/internal/roles/999"
}
"""
)})}),
@ApiResponse(responseCode = "404", description = "Role not found",
content = {@Content(schema = @Schema(implementation = StatusResponse.class),
examples = {@ExampleObject(value = """
{
"timestamp": 1717672263253,
"status": 404,
"error": "Not found",
"exception": "access.exception.NotFoundException",
"message": "Role not found",
"path": "/api/internal/roles/999"
}
"""
)})})})

public ResponseEntity<Void> deleteRole(@PathVariable("id") Long id,
@Parameter(hidden = true) @AuthenticationPrincipal RemoteUser remoteUser) {
Role role = roleRepository.findById(id).orElseThrow(() -> new NotFoundException("Role not found"));
Expand All @@ -254,7 +287,7 @@ public ResponseEntity<Void> deleteRole(@PathVariable("id") Long id,
@PostMapping("/invitations")
@PreAuthorize("hasRole('SP_DASHBOARD')")
@Operation(summary = "Invite member for existing Role",
description = "Invite a member for an existing role. An invitation email will be sent. Do not forget to set <guestRoleIncluded> to <true>",
description = "Invite a member for an existing role. An invitation email will be sent. Do not forget to set guestRoleIncluded to true.",
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
useParameterTypeSchema = true,
content = {@Content(examples = {@ExampleObject(value = """
Expand Down

0 comments on commit 45e45fb

Please sign in to comment.