Merge pull request #2525 from hongwei1/bugfix/swaggerIssue

Bugfix/swagger issue
This commit is contained in:
Simon Redfern 2025-04-09 11:46:23 +02:00 committed by GitHub
commit 0cd5da9593
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 787 additions and 744 deletions

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

@ -32,6 +32,7 @@ import com.openbankproject.commons.model.ListResult
import code.util.Helper.MdcLoggable
import net.liftweb.common.Box.tryo
import net.liftweb.common.{EmptyBox, Full}
import net.liftweb.http.provider.HTTPParam
import net.liftweb.json
import scala.collection.GenTraversableLike
@ -867,7 +868,7 @@ object SwaggerJSONFactory extends MdcLoggable {
case Some(v) => getNestedRefEntities(v, excludeTypes)
case Full(v) => getNestedRefEntities(v, excludeTypes)
case coll: Coll[_] => coll.toList.flatMap(getNestedRefEntities(_, excludeTypes))
case v if(! ReflectUtils.isObpObject(v)) => Nil
case v if(! ReflectUtils.isObpObject(v) && !obj.isInstanceOf[HTTPParam]) => Nil
case _ => {
val entityType = ReflectUtils.getType(obj)
val constructorParamList = ReflectUtils.getPrimaryConstructor(entityType).paramLists.headOption.getOrElse(Nil)

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.")
@ -1010,7 +1010,13 @@ object ExampleValue {
lazy val toTransferToAtmExample = ConnectorField(NoExampleProvided,NoDescriptionProvided)
glossaryItems += makeGlossaryItem("to_transfer_to_atm", toTransferToAtmExample)
lazy val jwtExample = ConnectorField(NoExampleProvided,NoDescriptionProvided)
lazy val jwtExample = ConnectorField("eyJhbGciOiJIUzI1NiJ9.eyJlbnRpdGxlbWVudHMiOltdLCJjcmVhdGVkQnlVc2VySWQiOiJhYjY1Mz" +
"lhOS1iMTA1LTQ0ODktYTg4My0wYWQ4ZDZjNjE2NTciLCJzdWIiOiIyMWUxYzhjYy1mOTE4LTRlYWMtYjhlMy01ZTVlZWM2YjNiNGIiLCJhdWQiOiJ" +
"lanpuazUwNWQxMzJyeW9tbmhieDFxbXRvaHVyYnNiYjBraWphanNrIiwibmJmIjoxNTUzNTU0ODk5LCJpc3MiOiJodHRwczpcL1wvd3d3Lm9wZW5i" +
"YW5rcHJvamVjdC5jb20iLCJleHAiOjE1NTM1NTg0OTksImlhdCI6MTU1MzU1NDg5OSwianRpIjoiMDlmODhkNWYtZWNlNi00Mzk4LThlOTktNjYxMW" +
"ZhMWNkYmQ1Iiwidmlld3MiOlt7ImFjY291bnRfaWQiOiJtYXJrb19wcml2aXRlXzAxIiwiYmFua19pZCI6ImdoLjI5LnVrLngiLCJ2aWV3X2lkIjoi" +
"b3duZXIifSx7ImFjY291bnRfaWQiOiJtYXJrb19wcml2aXRlXzAyIiwiYmFua19pZCI6ImdoLjI5LnVrLngiLCJ2aWV3X2lkIjoib3duZXIifV19." +
"8cc7cBEf2NyQvJoukBCmDLT7LXYcuzTcSYLqSpbxLp4","JSON Web Token")
glossaryItems += makeGlossaryItem("jwt", jwtExample)
lazy val requestedCurrentValidEndDateExample = ConnectorField(NoExampleProvided,NoDescriptionProvided)

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