From db04976f4f32c6252ead264d0d61d95717bc1cdf Mon Sep 17 00:00:00 2001 From: Danish Jamal Date: Sun, 8 Aug 2021 06:24:23 +0530 Subject: [PATCH] PostAuthenticationRequest schema added for auth body payload (FINERACT-1369) --- .../security/api/AuthenticationApiResource.java | 5 ++++- .../api/AuthenticationApiResourceSwagger.java | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/api/AuthenticationApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/api/AuthenticationApiResource.java index dba7ea5e4..f10279250 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/api/AuthenticationApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/api/AuthenticationApiResource.java @@ -21,8 +21,10 @@ package org.apache.fineract.infrastructure.security.api; import com.google.gson.Gson; import com.sun.jersey.core.util.Base64; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; +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.tags.Tag; @@ -93,10 +95,11 @@ public class AuthenticationApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @Operation(summary = "Verify authentication", description = "Authenticates the credentials provided and returns the set roles and permissions allowed.") + @RequestBody(required = true, content = @Content(schema = @Schema(implementation = AuthenticationApiResourceSwagger.PostAuthenticationRequest.class))) @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = AuthenticationApiResourceSwagger.PostAuthenticationResponse.class))), @ApiResponse(responseCode = "400", description = "Unauthenticated. Please login") }) - public String authenticate(final String apiRequestBodyAsJson, + public String authenticate(@Parameter(hidden = true) final String apiRequestBodyAsJson, @QueryParam("returnClientList") @DefaultValue("false") boolean returnClientList) { // TODO FINERACT-819: sort out Jersey so JSON conversion does not have // to be done explicitly via GSON here, but implicit by arg diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/api/AuthenticationApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/api/AuthenticationApiResourceSwagger.java index efc555985..22a7d179e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/api/AuthenticationApiResourceSwagger.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/security/api/AuthenticationApiResourceSwagger.java @@ -32,6 +32,19 @@ final class AuthenticationApiResourceSwagger { } + @Schema(description = "PostAuthenticationRequest") + public static final class PostAuthenticationRequest { + + private PostAuthenticationRequest() { + + } + + @Schema(required = true, example = "mifos") + public String username; + @Schema(required = true, example = "password") + public String password; + } + @Schema(description = "PostAuthenticationResponse") public static final class PostAuthenticationResponse {