Skip to content

Commit

Permalink
Add API response codes to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl committed Oct 2, 2023
1 parent dc48ae9 commit 85d49c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package uk.gov.justice.digital.hmpps.controller

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import io.swagger.v3.oas.annotations.tags.Tag
import jakarta.validation.Valid
import org.slf4j.LoggerFactory
Expand All @@ -26,6 +29,13 @@ class AuthenticationController(private val ldapTemplate: LdapTemplate) {
@PostMapping("/authenticate")
@PreAuthorize("hasRole('ROLE_DELIUS_USER_AUTH')")
@Operation(description = "Authenticate a Delius username and password. Requires `ROLE_DELIUS_USER_AUTH`.")
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "User authenticated", content = [Content(mediaType = "text/plain")]),
ApiResponse(responseCode = "401", description = "Authentication failure", content = [Content(mediaType = "text/plain")]),
ApiResponse(responseCode = "403", description = "Client role required: `ROLE_DELIUS_USER_AUTH`", content = [Content(mediaType = "text/plain")])
]
)
fun authenticate(
@Valid @RequestBody
request: AuthenticationRequest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package uk.gov.justice.digital.hmpps.controller

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import io.swagger.v3.oas.annotations.tags.Tag
import jakarta.validation.Valid
import jakarta.validation.constraints.NotBlank
Expand Down Expand Up @@ -34,6 +36,12 @@ class UserController(private val userService: UserService) {
@PostMapping("/user/{username}/password")
@PreAuthorize("hasRole('ROLE_DELIUS_USER_AUTH')")
@Operation(description = "Change a Delius user's password. Requires `ROLE_DELIUS_USER_AUTH`.")
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "Password changed successfully"),
ApiResponse(responseCode = "404", description = "User not found")
]
)
fun changePassword(
@PathVariable("username") @NotBlank username: String,
@Valid @RequestBody
Expand Down

0 comments on commit 85d49c9

Please sign in to comment.