bugfix/fixed the swagger endpoint issue

This commit is contained in:
hongwei 2025-04-08 14:20:06 +02:00
parent 225cb62812
commit 83523e0f2c
8 changed files with 101 additions and 65 deletions

View File

@ -504,6 +504,11 @@ object SwaggerDefinitionsJSON {
)
val transactionRequestCounterpartyId = TransactionRequestCounterpartyId (counterparty_id = counterpartyIdExample.value)
val transactionRequestAgentCashWithdrawal = TransactionRequestAgentCashWithdrawal(
bank_id = bankIdExample.value,
agent_number = agentNumberExample.value
)
val transactionRequestIban = TransactionRequestIban (iban = "String")
@ -619,6 +624,7 @@ object SwaggerDefinitionsJSON {
to_transfer_to_atm = Some(transactionRequestTransferToAtm),
to_transfer_to_account = Some(transactionRequestTransferToAccount),
to_sepa_credit_transfers = Some(sepaCreditTransfers),
to_agent = Some(transactionRequestAgentCashWithdrawal),
value = amountOfMoney,
description = descriptionExample.value
)
@ -1914,6 +1920,7 @@ object SwaggerDefinitionsJSON {
role_name = "CanQueryOtherUser",
bank_id = bankIdExample.value
)
val entitlementJSONs = EntitlementJSONs(
list = List(entitlementJSON)
)
@ -4185,6 +4192,61 @@ object SwaggerDefinitionsJSON {
api_version = "v1.3"
)
val helperInfoJson = HelperInfoJson(
counterparty_ids = List(counterpartyIdExample.value)
)
val roleJsonV510 = code.api.util.Role(
role_name = roleNameExample.value,
bank_id = bankIdExample.value
)
val httpParam = net.liftweb.http.provider.HTTPParam(
name = "tags",
values = List("static")
)
val consentAccessAccountsJson =code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.ConsentAccessAccountsJson(
iban = Some(ibanExample.value),
bban = Some("BARC12345612345678"),
pan = Some("5409050000000000"),
maskedPan = Some("123456xxxxxx1234"),
msisdn = Some("+49 170 1234567"),
currency = Some(currencyExample.value)
)
val consentAccessJson = code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.ConsentAccessJson(
accounts = Some(List(consentAccessAccountsJson)),
balances = Some(List(consentAccessAccountsJson)),
transactions = Some(List(consentAccessAccountsJson)),
availableAccounts = Some(accountIdExample.value),
allPsd2 = None
)
val consentView = code.api.util.ConsentView(
bank_id = bankIdExample.value,
account_id = accountIdExample.value,
view_id = viewIdExample.value,
helper_info = Some(helperInfoJson)
)
val consentJWT = code.api.util.ConsentJWT(
createdByUserId = userIdExample.value,
sub = subExample.value,
iss = issExample.value,
aud = audExample.value,
jti = jtiExample.value,
iat = iatExample.value.toLong,
nbf = nbfExample.value.toLong,
exp = expExample.value.toLong,
request_headers = List(httpParam),
name = Some(nameExample.value),
email= Some(emailExample.value),
entitlements = List(roleJsonV510),
views = List(consentView),
access = Some(consentAccessJson)
)
val allConsentJsonV510 = AllConsentJsonV510(
consent_reference_id = "9d429899-24f5-42c8-8565-943ffa6a7945",
consumer_id = consumerIdExample.value,
@ -4194,8 +4256,25 @@ object SwaggerDefinitionsJSON {
status = ConsentStatus.INITIATED.toString,
api_standard = "Berlin Group",
api_version = "v1.3",
jwt_payload = SwaggerDefinitionsJsonUtil.jwtPayload,
jwt_payload = Some(consentJWT)
)
val consentInfoJsonV510 = ConsentInfoJsonV510(
consent_id = consentIdExample.value,
consumer_id = consumerIdExample.value,
created_by_user_id = userIdExample.value,
status = statusExample.value,
last_action_date = dateExample.value,
last_usage_date = dateTimeExample.value,
jwt = jwtExample.value,
jwt_payload = Some(consentJWT),
api_standard = "Berlin Group",
api_version = "v1.3",
)
val consentsInfoJsonV510 = ConsentsInfoJsonV510(
consents = List(consentInfoJsonV510)
)
val consentsJsonV510 = ConsentsJsonV510(List(allConsentJsonV510))
val revokedConsentJsonV310 = ConsentJsonV310(
@ -5190,11 +5269,7 @@ object SwaggerDefinitionsJSON {
consumer_id = consumerIdExample.value
)
val helperInfoJson = HelperInfoJson(
counterparty_ids = List(counterpartyIdExample.value)
)
val consentAccountAccessJson= ConsentAccountAccessJson(
val consentAccountAccessJson = ConsentAccountAccessJson(
bank_id = bankIdExample.value,
account_id = accountIdExample.value,
view_id = viewIdExample.value,
@ -5213,7 +5288,7 @@ object SwaggerDefinitionsJSON {
jwt = "eyJhbGciOiJIUzI1NiJ9.eyJlbnRpdGxlbWVudHMiOltdLCJjcmVhdGVkQnlVc2VySWQiOiJhYjY1MzlhOS1iMTA1LTQ0ODktYTg4My0wYWQ4ZDZjNjE2NTciLCJzdWIiOiIyMWUxYzhjYy1mOTE4LTRlYWMtYjhlMy01ZTVlZWM2YjNiNGIiLCJhdWQiOiJlanpuazUwNWQxMzJyeW9tbmhieDFxbXRvaHVyYnNiYjBraWphanNrIiwibmJmIjoxNTUzNTU0ODk5LCJpc3MiOiJodHRwczpcL1wvd3d3Lm9wZW5iYW5rcHJvamVjdC5jb20iLCJleHAiOjE1NTM1NTg0OTksImlhdCI6MTU1MzU1NDg5OSwianRpIjoiMDlmODhkNWYtZWNlNi00Mzk4LThlOTktNjYxMWZhMWNkYmQ1Iiwidmlld3MiOlt7ImFjY291bnRfaWQiOiJtYXJrb19wcml2aXRlXzAxIiwiYmFua19pZCI6ImdoLjI5LnVrLngiLCJ2aWV3X2lkIjoib3duZXIifSx7ImFjY291bnRfaWQiOiJtYXJrb19wcml2aXRlXzAyIiwiYmFua19pZCI6ImdoLjI5LnVrLngiLCJ2aWV3X2lkIjoib3duZXIifV19.8cc7cBEf2NyQvJoukBCmDLT7LXYcuzTcSYLqSpbxLp4",
status = ConsentStatus.INITIATED.toString,
consent_request_id = Some(consentRequestIdExample.value),
scopes = None,
scopes = Some(List(roleJsonV510)),
consumer_id= consumerIdExample.value
)
@ -5574,7 +5649,7 @@ object SwaggerDefinitionsJSON {
val minimalAgentsJsonV510 = MinimalAgentsJsonV510(
agents = List(minimalAgentJsonV510)
)
//The common error or success format.
//Just some helper format to use in Json
case class NotSupportedYet()

View File

@ -1,39 +0,0 @@
package code.api.ResourceDocs1_4_0
import code.api.util.ConsentJWT
import net.liftweb.json._
object SwaggerDefinitionsJsonUtil {
implicit val formats: Formats = DefaultFormats
// General method to parse JSON into any case class
def parseJsonToCaseClass[T](jsonString: String)(implicit mf: Manifest[T]): Option[T] = {
parse(jsonString).extractOpt[T]
}
// Usage example with ConsentJWT, or replace ConsentJWT with any other case class
val jwtPayload: Option[ConsentJWT] = parseJsonToCaseClass[ConsentJWT](
"""{
"createdByUserId": "",
"sub": "fcf346d2-153b-4430-9a8f-f35768533987",
"iss": "https://127.0.0.1:8080",
"aud": "2664650c-8090-481e-8bd8-03a92f9c87ea",
"jti": "d33f7463-ee49-4e8a-8a92-6138dc183d16",
"iat": 1730373271,
"nbf": 1730373271,
"exp": 1730937600,
"request_headers":[],
"entitlements": [],
"views": [ {
"bank_id": "nlbkb",
"account_id": "95389297-45c4-40eb-9efd-331ba1943da4",
"view_id": "ReadAccountsBerlinGroup"
}],
"access": {
"accounts": [ {
"iban": "RS35260005601001611379"
}]
}
}"""
)
}

View File

@ -258,9 +258,9 @@ object ExampleValue {
lazy val issExample = ConnectorField("String","The Issuer Identifier for the Issuer of the response.")
lazy val audExample = ConnectorField("String","Identifies the audience that this ID token is intended for. It must be one of the OBP-API client IDs of your application.")
lazy val jtiExample = ConnectorField("String","(JWT ID) claim provides a unique identifier for the JWT.")
lazy val iatExample = ConnectorField("String","The iat (issued at) claim identifies the time at which the JWT was issued. Represented in Unix time (integer seconds).")
lazy val nbfExample = ConnectorField("String","The nbf (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. Represented in Unix time (integer seconds).")
lazy val expExample = ConnectorField("String","The exp (expiration time) claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing. Represented in Unix time (integer seconds).")
lazy val iatExample = ConnectorField("60","The iat (issued at) claim identifies the time at which the JWT was issued. Represented in Unix time (integer seconds).")
lazy val nbfExample = ConnectorField("60","The nbf (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. Represented in Unix time (integer seconds).")
lazy val expExample = ConnectorField("60","The exp (expiration time) claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing. Represented in Unix time (integer seconds).")
lazy val emailVerifiedExample = ConnectorField("String","If the email is verified or not.")
lazy val emailExample = ConnectorField(s"${userNameExample.value}@example.com", "An email address.")

View File

@ -1532,7 +1532,7 @@ trait APIMethods510 {
|
""".stripMargin,
EmptyBody,
consentsJsonV400,
consentsInfoJsonV510,
List(
$UserNotLoggedIn,
$BankNotFound,
@ -1571,7 +1571,7 @@ trait APIMethods510 {
|
""".stripMargin,
EmptyBody,
consentsJsonV400,
consentsInfoJsonV510,
List(
$UserNotLoggedIn,
$BankNotFound,

View File

@ -894,7 +894,7 @@ object JSONFactory510 extends CustomJsonFormats {
def createConsentsJsonV510(consents: List[MappedConsent]): ConsentsJsonV510 = {
ConsentsJsonV510(
consents.map { c =>
val jwtPayload: Box[ConsentJWT] = JwtUtil.getSignedPayloadAsJson(c.jsonWebToken).map(parse(_).extract[ConsentJWT])
val jwtPayload = JwtUtil.getSignedPayloadAsJson(c.jsonWebToken).map(parse(_).extract[ConsentJWT]).toOption
AllConsentJsonV510(
consent_reference_id = c.consentReferenceId,
consumer_id = c.consumerId,

View File

@ -2349,7 +2349,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
amount=amountExample.value),
creditorAccount=PaymentAccount("string"),
creditorName="string")),
to_agent=Some( transactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
to_agent=Some( TransactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
agent_number="string")),
value= AmountOfMoney(currency=currencyExample.value,
amount=amountExample.value),
@ -2514,7 +2514,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
amount=amountExample.value),
creditorAccount=PaymentAccount("string"),
creditorName="string")),
to_agent=Some( transactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
to_agent=Some( TransactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
agent_number="string")),
value= AmountOfMoney(currency=currencyExample.value,
amount=amountExample.value),
@ -2865,7 +2865,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
amount=amountExample.value),
creditorAccount=PaymentAccount("string"),
creditorName="string")),
to_agent=Some( transactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
to_agent=Some( TransactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
agent_number="string")),
value= AmountOfMoney(currency=currencyExample.value,
amount=amountExample.value),
@ -2971,7 +2971,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
amount=amountExample.value),
creditorAccount=PaymentAccount("string"),
creditorName="string")),
to_agent=Some( transactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
to_agent=Some( TransactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
agent_number="string")),
value= AmountOfMoney(currency=currencyExample.value,
amount=amountExample.value),
@ -3143,7 +3143,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
amount=amountExample.value),
creditorAccount=PaymentAccount("string"),
creditorName="string")),
to_agent=Some( transactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
to_agent=Some( TransactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
agent_number="string")),
value= AmountOfMoney(currency=currencyExample.value,
amount=amountExample.value),
@ -3228,7 +3228,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
amount=amountExample.value),
creditorAccount=PaymentAccount("string"),
creditorName="string")),
to_agent=Some( transactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
to_agent=Some( TransactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
agent_number="string")),
value= AmountOfMoney(currency=currencyExample.value,
amount=amountExample.value),
@ -3899,7 +3899,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
amount=amountExample.value),
creditorAccount=PaymentAccount("string"),
creditorName="string")),
to_agent=Some( transactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
to_agent=Some( TransactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
agent_number="string")),
value= AmountOfMoney(currency=currencyExample.value,
amount=amountExample.value),
@ -4171,7 +4171,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
amount=amountExample.value),
creditorAccount=PaymentAccount("string"),
creditorName="string")),
to_agent=Some( transactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
to_agent=Some( TransactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
agent_number="string")),
value= AmountOfMoney(currency=currencyExample.value,
amount=amountExample.value),
@ -4272,7 +4272,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
amount=amountExample.value),
creditorAccount=PaymentAccount("string"),
creditorName="string")),
to_agent=Some( transactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
to_agent=Some( TransactionRequestAgentCashWithdrawal(bank_id=bank_idExample.value,
agent_number="string")),
value= AmountOfMoney(currency=currencyExample.value,
amount=amountExample.value),

View File

@ -394,7 +394,7 @@ class MappedTransactionRequest extends LongKeyedMapper[MappedTransactionRequest]
agentNumber
val agentNumberValue = if (agentNumberList.isEmpty) "" else agentNumberList.head
val bankIdValue = if (bankIdList.isEmpty) "" else bankIdList.head
Some(transactionRequestAgentCashWithdrawal(
Some(TransactionRequestAgentCashWithdrawal(
bank_id = bankIdValue,
agent_number = agentNumberValue
))

View File

@ -912,7 +912,7 @@ object RegulatedEntityTraitCommons extends Converter[RegulatedEntityTrait, Regul
case class TransactionRequestCounterpartyId (counterparty_id : String)
//For AGENT_CASH_WITHDRAWAL, it needs the agent_number to find the toAgent--> toBankAccount
case class transactionRequestAgentCashWithdrawal (bank_id: String , agent_number : String)
case class TransactionRequestAgentCashWithdrawal (bank_id: String , agent_number : String)
case class TransactionRequestSimple (
otherBankRoutingScheme: String,
@ -1026,7 +1026,7 @@ case class TransactionRequestBodyAllTypes (
@optional
to_sepa_credit_transfers: Option[SepaCreditTransfers]= None,//TODO not stable, from berlin Group
@optional
to_agent: Option[transactionRequestAgentCashWithdrawal]= None,
to_agent: Option[TransactionRequestAgentCashWithdrawal]= None,
value: AmountOfMoney,
description: String