From de3428f786e5443329812f6f6a986c7637a41664 Mon Sep 17 00:00:00 2001 From: rayankonecny Date: Sun, 14 Dec 2025 03:39:21 +0000 Subject: [PATCH] add athenticate contract controller --- .../controllers/AuthController.java | 26 +++++++++++++++++-- .../src/main/resources/application.yml | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/auth-service-api/src/main/java/br/com/rayankonecny/authserviceapi/controllers/AuthController.java b/auth-service-api/src/main/java/br/com/rayankonecny/authserviceapi/controllers/AuthController.java index 2007feb..dd9d4a5 100644 --- a/auth-service-api/src/main/java/br/com/rayankonecny/authserviceapi/controllers/AuthController.java +++ b/auth-service-api/src/main/java/br/com/rayankonecny/authserviceapi/controllers/AuthController.java @@ -4,10 +4,32 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import br.com.rayankonecny.hdcommoslib.models.exceptions.StandardError; +import br.com.rayankonecny.hdcommoslib.models.requests.AuthenticateRequest; +import br.com.rayankonecny.hdcommoslib.models.responses.AuthenticationResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; + +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + + @RequestMapping("/auth") public interface AuthController { + @Operation(summary = "Authenticate user") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "User authenticated", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = AuthenticationResponse.class))), + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = StandardError.class))), + @ApiResponse(responseCode = "401", description = "Bad credentials", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = StandardError.class))), + @ApiResponse(responseCode = "404", description = "Username not found", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = StandardError.class))), + @ApiResponse(responseCode = "500", description = "Internal server error", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = StandardError.class))), + }) @PostMapping("/login") - ResponseEntity authenticate(); - + ResponseEntity authenticate(@Valid @RequestBody final AuthenticateRequest requests); + } diff --git a/auth-service-api/src/main/resources/application.yml b/auth-service-api/src/main/resources/application.yml index d908854..d2dccde 100644 --- a/auth-service-api/src/main/resources/application.yml +++ b/auth-service-api/src/main/resources/application.yml @@ -1,3 +1,4 @@ spring: application: name: "auth-service-api" + \ No newline at end of file