From 15fe5e446190710ff43100702526be44fd47682e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 7 Sep 2023 10:55:30 +0200 Subject: [PATCH 1/5] refactor/Enable request timeout at endpoint root v4.0.0 --- .../src/main/scala/code/api/v4_0_0/APIMethods400.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala index 41e672a555..5a21ecd152 100644 --- a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala +++ b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala @@ -2704,9 +2704,11 @@ trait APIMethods400 { def root (apiVersion : ApiVersion, apiVersionStatus: String): OBPEndpoint = { case (Nil | "root" :: Nil) JsonGet _ => { cc => - implicit val ec = EndpointContext(Some(cc)) - Future { - getApiInfoJSON(apiVersion, apiVersionStatus) -> HttpCode.`200`(cc.callContext) + implicit val ec = EndpointContext(Some(cc)) + for { + _ <- Future() // Just start async call + } yield { + (getApiInfoJSON(apiVersion,apiVersionStatus), HttpCode.`200`(cc.callContext)) } } } From 403ca73c618495c65c782286b91c8b6f774f48c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 7 Sep 2023 10:56:35 +0200 Subject: [PATCH 2/5] refactor/Make root v1.2.1 as a new style endpoint --- .../main/scala/code/api/v1_2_1/APIMethods121.scala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/obp-api/src/main/scala/code/api/v1_2_1/APIMethods121.scala b/obp-api/src/main/scala/code/api/v1_2_1/APIMethods121.scala index fc94233cc7..2881e66f51 100644 --- a/obp-api/src/main/scala/code/api/v1_2_1/APIMethods121.scala +++ b/obp-api/src/main/scala/code/api/v1_2_1/APIMethods121.scala @@ -155,8 +155,15 @@ trait APIMethods121 { apiTagApi :: Nil) def root(apiVersion : ApiVersion, apiVersionStatus: String) : OBPEndpoint = { - case "root" :: Nil JsonGet req => cc =>Full(successJsonResponse(getApiInfoJSON(apiVersion, apiVersionStatus), 200)) - case Nil JsonGet req => cc =>Full(successJsonResponse(getApiInfoJSON(apiVersion, apiVersionStatus), 200)) + case (Nil | "root" :: Nil) JsonGet _ => { + cc => + implicit val ec = EndpointContext(Some(cc)) + for { + _ <- Future() // Just start async call + } yield { + (getApiInfoJSON(apiVersion,apiVersionStatus), HttpCode.`200`(cc.callContext)) + } + } } From 8c468114612917658c31debb0923837a257a3004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 7 Sep 2023 11:53:18 +0200 Subject: [PATCH 3/5] refactor/Enable request timeout at endpoint get call context v4.0.0 --- obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala index 5a21ecd152..9741aeab10 100644 --- a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala +++ b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala @@ -2734,7 +2734,9 @@ trait APIMethods400 { case "development" :: "call_context" :: Nil JsonGet _ => { cc => implicit val ec = EndpointContext(Some(cc)) - Future{ + for { + _ <- Future() // Just start async call + } yield { (cc.callContext, HttpCode.`200`(cc.callContext)) } } From f44c4b69a8d99f3f639f7aeaa7166b8a3362a4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 7 Sep 2023 12:21:30 +0200 Subject: [PATCH 4/5] refactor/Enable request timeout at endpoint verifyRequestSignResponse v4.0.0 --- obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala index 9741aeab10..1c25613a68 100644 --- a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala +++ b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala @@ -2762,7 +2762,9 @@ trait APIMethods400 { case "development" :: "echo":: "jws-verified-request-jws-signed-response" :: Nil JsonGet _ => { cc => implicit val ec = EndpointContext(Some(cc)) - Future{ + for { + _ <- Future() // Just start async call + } yield { (cc.callContext, HttpCode.`200`(cc.callContext)) } } From 57db2499934b09f7d5555bdc268e5c8b7b2bfb1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Thu, 7 Sep 2023 14:01:19 +0200 Subject: [PATCH 5/5] feature/Add tag Old-Style in case of v1.2.1 --- .../src/main/scala/code/api/util/ApiTag.scala | 1 + .../scala/code/api/v1_2_1/APIMethods121.scala | 44 +++++++++---------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/obp-api/src/main/scala/code/api/util/ApiTag.scala b/obp-api/src/main/scala/code/api/util/ApiTag.scala index 51d237bba8..27ae8c1dff 100644 --- a/obp-api/src/main/scala/code/api/util/ApiTag.scala +++ b/obp-api/src/main/scala/code/api/util/ApiTag.scala @@ -13,6 +13,7 @@ object ApiTag { // Use the *singular* case. for both the variable name and string. // e.g. "This call is Payment related" // When using these tags in resource docs, as we now have many APIs, it's best not to have too use too many tags per endpoint. + val apiTagOldStyle = ResourceDocTag("Old-Style") val apiTagTransactionRequest = ResourceDocTag("Transaction-Request") val apiTagApi = ResourceDocTag("API") val apiTagBank = ResourceDocTag("Bank") diff --git a/obp-api/src/main/scala/code/api/v1_2_1/APIMethods121.scala b/obp-api/src/main/scala/code/api/v1_2_1/APIMethods121.scala index 2881e66f51..22c2d30cbf 100644 --- a/obp-api/src/main/scala/code/api/v1_2_1/APIMethods121.scala +++ b/obp-api/src/main/scala/code/api/v1_2_1/APIMethods121.scala @@ -184,7 +184,7 @@ trait APIMethods121 { emptyObjectJson, banksJSON, List(UnknownError), - apiTagBank :: apiTagPsd2 :: Nil) + apiTagBank :: apiTagPsd2 :: apiTagOldStyle :: Nil) lazy val getBanks : OBPEndpoint = { //get banks @@ -219,7 +219,7 @@ trait APIMethods121 { emptyObjectJson, bankJSON, List(UserNotLoggedIn, UnknownError, BankNotFound), - apiTagBank :: apiTagPsd2 :: Nil) + apiTagBank :: apiTagPsd2 :: apiTagOldStyle :: Nil) lazy val bankById : OBPEndpoint = { @@ -251,7 +251,7 @@ trait APIMethods121 { emptyObjectJson, accountJSON, List(UserNotLoggedIn, UnknownError), - apiTagAccount :: apiTagPsd2 :: Nil) + apiTagAccount :: apiTagPsd2 :: apiTagOldStyle :: Nil) //TODO double check with `lazy val privateAccountsAllBanks :`, they are the same now. lazy val getPrivateAccountsAllBanks : OBPEndpoint = { @@ -284,7 +284,7 @@ trait APIMethods121 { emptyObjectJson, accountJSON, List(UserNotLoggedIn, UnknownError), - apiTagAccount :: apiTagPsd2 :: Nil) + apiTagAccount :: apiTagPsd2 :: apiTagOldStyle :: Nil) lazy val privateAccountsAllBanks : OBPEndpoint = { //get private accounts for all banks @@ -316,7 +316,7 @@ trait APIMethods121 { emptyObjectJson, accountJSON, List(UnknownError), - apiTagAccount :: Nil) + apiTagAccount :: apiTagOldStyle :: Nil) lazy val publicAccountsAllBanks : OBPEndpoint = { //get public accounts for all banks @@ -348,7 +348,7 @@ trait APIMethods121 { emptyObjectJson, accountJSON, List(UserNotLoggedIn, UnknownError, BankNotFound), - apiTagAccount :: Nil) + apiTagAccount :: apiTagOldStyle :: Nil) lazy val getPrivateAccountsAtOneBank : OBPEndpoint = { //get accounts for a single bank (private + public) @@ -381,7 +381,7 @@ trait APIMethods121 { emptyObjectJson, accountJSON, List(UserNotLoggedIn, UnknownError, BankNotFound), - List(apiTagAccount, apiTagPsd2)) + List(apiTagAccount, apiTagPsd2, apiTagOldStyle)) lazy val privateAccountsAtOneBank : OBPEndpoint = { //get private accounts for a single bank @@ -413,7 +413,7 @@ trait APIMethods121 { emptyObjectJson, accountJSON, List(UserNotLoggedIn, UnknownError, BankNotFound), - apiTagAccountPublic :: apiTagAccount :: apiTagPublicData :: Nil) + apiTagAccountPublic :: apiTagAccount :: apiTagPublicData :: apiTagOldStyle :: Nil) lazy val publicAccountsAtOneBank : OBPEndpoint = { //get public accounts for a single bank @@ -456,7 +456,7 @@ trait APIMethods121 { emptyObjectJson, moderatedAccountJSON, List(UserNotLoggedIn, UnknownError, BankAccountNotFound), - apiTagAccount :: Nil) + apiTagAccount :: apiTagOldStyle :: Nil) lazy val accountById : OBPEndpoint = { //get account by id @@ -558,7 +558,7 @@ trait APIMethods121 { emptyObjectJson, viewsJSONV121, List(UserNotLoggedIn, BankAccountNotFound, UnknownError, "user does not have owner access"), - List(apiTagView, apiTagAccount)) + List(apiTagView, apiTagAccount, apiTagOldStyle)) lazy val getViewsForBankAccount : OBPEndpoint = { //get the available views on an bank account @@ -610,7 +610,7 @@ trait APIMethods121 { UnknownError, "user does not have owner access" ), - List(apiTagAccount, apiTagView) + List(apiTagAccount, apiTagView, apiTagOldStyle) ) lazy val createViewForBankAccount : OBPEndpoint = { @@ -669,7 +669,7 @@ trait APIMethods121 { UnknownError, "user does not have owner access" ), - List(apiTagAccount, apiTagView) + List(apiTagAccount, apiTagView, apiTagOldStyle) ) lazy val updateViewForBankAccount: OBPEndpoint = { @@ -768,7 +768,7 @@ trait APIMethods121 { emptyObjectJson, permissionsJSON, List(UserNotLoggedIn, UnknownError), - List(apiTagView, apiTagAccount, apiTagEntitlement) + List(apiTagView, apiTagAccount, apiTagEntitlement, apiTagOldStyle) ) lazy val getPermissionsForBankAccount: OBPEndpoint = { @@ -811,7 +811,7 @@ trait APIMethods121 { UnknownError, "user does not have access to owner view on account" ), - List(apiTagAccount, apiTagView, apiTagEntitlement) + List(apiTagAccount, apiTagView, apiTagEntitlement, apiTagOldStyle) ) @@ -1035,7 +1035,7 @@ trait APIMethods121 { BankAccountNotFound, UnknownError ), - List(apiTagCounterparty, apiTagAccount, apiTagPsd2)) + List(apiTagCounterparty, apiTagAccount, apiTagPsd2, apiTagOldStyle)) lazy val getOtherAccountsForBankAccount : OBPEndpoint = { //get other accounts for one account @@ -1065,7 +1065,7 @@ trait APIMethods121 { emptyObjectJson, otherAccountJSON, List(BankAccountNotFound, UnknownError), - List(apiTagCounterparty, apiTagAccount)) + List(apiTagCounterparty, apiTagAccount, apiTagOldStyle)) lazy val getOtherAccountByIdForBankAccount : OBPEndpoint = { //get one other account by id @@ -2108,7 +2108,7 @@ trait APIMethods121 { "Coordinates not possible", "Corporate Location cannot be deleted", UnknownError), - List(apiTagCounterpartyMetaData, apiTagCounterparty)) + List(apiTagCounterpartyMetaData, apiTagCounterparty, apiTagOldStyle)) lazy val addCounterpartyCorporateLocation : OBPEndpoint = { //add corporate location to other bank account @@ -2151,7 +2151,7 @@ trait APIMethods121 { "Coordinates not possible", "Corporate Location cannot be updated", UnknownError), - List(apiTagCounterpartyMetaData, apiTagCounterparty)) + List(apiTagCounterpartyMetaData, apiTagCounterparty, apiTagOldStyle)) lazy val updateCounterpartyCorporateLocation : OBPEndpoint = { //update corporate location of other bank account @@ -2243,7 +2243,7 @@ trait APIMethods121 { "Coordinates not possible", "Physical Location cannot be added", UnknownError), - List(apiTagCounterpartyMetaData, apiTagCounterparty)) + List(apiTagCounterpartyMetaData, apiTagCounterparty, apiTagOldStyle)) lazy val addCounterpartyPhysicalLocation : OBPEndpoint = { //add physical location to other bank account @@ -2287,7 +2287,7 @@ trait APIMethods121 { "Coordinates not possible", "Physical Location cannot be updated", UnknownError), - List(apiTagCounterpartyMetaData, apiTagCounterparty)) + List(apiTagCounterpartyMetaData, apiTagCounterparty, apiTagOldStyle)) lazy val updateCounterpartyPhysicalLocation : OBPEndpoint = { //update physical location to other bank account @@ -2376,7 +2376,7 @@ trait APIMethods121 { emptyObjectJson, transactionsJSON, List(BankAccountNotFound, UnknownError), - List(apiTagTransaction, apiTagAccount, apiTagPsd2)) + List(apiTagTransaction, apiTagAccount, apiTagPsd2, apiTagOldStyle)) @@ -2442,7 +2442,7 @@ trait APIMethods121 { emptyObjectJson, transactionJSON, List(BankAccountNotFound, UnknownError), - List(apiTagTransaction, apiTagPsd2)) + List(apiTagTransaction, apiTagPsd2, apiTagOldStyle)) lazy val getTransactionByIdForBankAccount : OBPEndpoint = { //get transaction by id