mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 13:26:51 +00:00
Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
16b89b672e
@ -4,6 +4,7 @@ import code.api.Constant.PARAM_LOCALE
|
||||
|
||||
import java.util.UUID.randomUUID
|
||||
import code.api.OBPRestHelper
|
||||
import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON.canGetCustomersJson
|
||||
import code.api.builder.OBP_APIBuilder
|
||||
import code.api.cache.Caching
|
||||
import code.api.dynamic.endpoint.helper.{DynamicEndpointHelper, DynamicEndpoints}
|
||||
@ -24,7 +25,7 @@ import code.util.Helper.MdcLoggable
|
||||
import com.github.dwickern.macros.NameOf.nameOf
|
||||
import com.openbankproject.commons.model.{BankId, ListResult, User}
|
||||
import com.openbankproject.commons.model.enums.ContentParam.{ALL, DYNAMIC, STATIC}
|
||||
import com.openbankproject.commons.model.enums.{ContentParam}
|
||||
import com.openbankproject.commons.model.enums.ContentParam
|
||||
import com.openbankproject.commons.util.ApiStandards._
|
||||
import com.openbankproject.commons.util.{ApiVersion, ScannedApiVersion}
|
||||
import com.tesobe.CacheKeyFromArguments
|
||||
@ -176,11 +177,8 @@ trait ResourceDocsAPIMethods extends MdcLoggable with APIMethods220 with APIMeth
|
||||
{
|
||||
// only `obp` standard show the `localResourceDocs`
|
||||
case version: ScannedApiVersion
|
||||
if(version.apiStandard == obp.toString && version==ApiVersion.v4_0_0) =>
|
||||
activePlusLocalResourceDocs ++= localResourceDocs.filterNot(_.partialFunctionName == nameOf(getResourceDocsObp))
|
||||
case version: ScannedApiVersion
|
||||
if(version.apiStandard == obp.toString && version!=ApiVersion.v4_0_0) =>
|
||||
activePlusLocalResourceDocs ++= localResourceDocs.filterNot(_.partialFunctionName == nameOf(getResourceDocsObpV400))
|
||||
if(version.apiStandard == obp.toString) =>
|
||||
activePlusLocalResourceDocs ++= localResourceDocs
|
||||
case _ => ; // all other standards only show their own apis.
|
||||
}
|
||||
|
||||
@ -410,7 +408,9 @@ trait ResourceDocsAPIMethods extends MdcLoggable with APIMethods220 with APIMeth
|
||||
emptyObjectJson,
|
||||
emptyObjectJson,
|
||||
UnknownError :: Nil,
|
||||
List(apiTagDocumentation))
|
||||
List(apiTagDocumentation),
|
||||
Some(List(canGetCustomersJson))
|
||||
)
|
||||
|
||||
|
||||
val exampleResourceDocsJson = JSONFactory1_4_0.createResourceDocsJson(List(exampleResourceDoc), false, None)
|
||||
|
||||
@ -11,7 +11,7 @@ import code.api.dynamic.endpoint.helper.practise.PractiseEndpoint
|
||||
import code.api.util.APIUtil.{defaultJValue, _}
|
||||
import code.api.util.ApiRole._
|
||||
import code.api.util.ExampleValue._
|
||||
import code.api.util.{APIUtil, ApiTrigger, ExampleValue}
|
||||
import code.api.util.{APIUtil, ApiRole, ApiTrigger, ExampleValue}
|
||||
import code.api.v2_2_0.JSONFactory220.{AdapterImplementationJson, MessageDocJson, MessageDocsJson}
|
||||
import code.api.v3_0_0.JSONFactory300.createBranchJsonV300
|
||||
import code.api.v3_0_0.custom.JSONFactoryCustom300
|
||||
@ -31,7 +31,7 @@ import com.github.dwickern.macros.NameOf.nameOf
|
||||
import com.openbankproject.commons.model
|
||||
import com.openbankproject.commons.model.PinResetReason.{FORGOT, GOOD_SECURITY_PRACTICE}
|
||||
import com.openbankproject.commons.model.enums.{AttributeCategory, CardAttributeType, ChallengeType}
|
||||
import com.openbankproject.commons.model.{UserAuthContextUpdateStatus, ViewBasic, _}
|
||||
import com.openbankproject.commons.model.{TransactionRequestSimple, UserAuthContextUpdateStatus, ViewBasic, _}
|
||||
import com.openbankproject.commons.util.{ApiVersion, FieldNameApiVersions, ReflectUtils, RequiredArgs, RequiredInfo}
|
||||
import net.liftweb.json
|
||||
import java.net.URLEncoder
|
||||
@ -582,17 +582,29 @@ object SwaggerDefinitionsJSON {
|
||||
creditorAccount = PaymentAccount(iban = "DE75512108001245126199"),
|
||||
creditorName = "John Miles"
|
||||
)
|
||||
|
||||
val transactionRequestSimple= TransactionRequestSimple(
|
||||
otherBankRoutingScheme = bankRoutingSchemeExample.value,
|
||||
otherBankRoutingAddress = bankRoutingAddressExample.value,
|
||||
otherBranchRoutingScheme = branchRoutingSchemeExample.value,
|
||||
otherBranchRoutingAddress = branchRoutingAddressExample.value,
|
||||
otherAccountRoutingScheme = accountRoutingSchemeExample.value,
|
||||
otherAccountRoutingAddress = accountRoutingAddressExample.value,
|
||||
otherAccountSecondaryRoutingScheme = accountRoutingSchemeExample.value,
|
||||
otherAccountSecondaryRoutingAddress = accountRoutingAddressExample.value
|
||||
)
|
||||
|
||||
val transactionRequestBodyAllTypes = TransactionRequestBodyAllTypes (
|
||||
to_sandbox_tan = Some(transactionRequestAccount),
|
||||
to_sepa = Some(transactionRequestIban),
|
||||
to_counterparty = Some(transactionRequestCounterpartyId),
|
||||
to_simple = Some(transactionRequestSimple),
|
||||
to_transfer_to_phone = Some(transactionRequestTransferToPhone),
|
||||
to_transfer_to_atm = Some(transactionRequestTransferToAtm),
|
||||
to_transfer_to_account = Some(transactionRequestTransferToAccount),
|
||||
to_sepa_credit_transfers = Some(sepaCreditTransfers),
|
||||
value = amountOfMoney,
|
||||
description = "String"
|
||||
description = descriptionExample.value
|
||||
)
|
||||
|
||||
val transactionRequest = TransactionRequest(
|
||||
@ -1924,6 +1936,30 @@ object SwaggerDefinitionsJSON {
|
||||
entitlements = entitlementJSONs
|
||||
)
|
||||
|
||||
val userAgreementJson = UserAgreementJson(
|
||||
ExampleValue.typeExample.value,
|
||||
ExampleValue.textExample.value,
|
||||
)
|
||||
val viewJSON300 = ViewJSON300(
|
||||
bank_id = bankIdExample.value,
|
||||
account_id = accountIdExample.value,
|
||||
view_id = viewIdExample.value
|
||||
)
|
||||
|
||||
val viewsJSON300 = ViewsJSON300(
|
||||
list = List(viewJSON300)
|
||||
)
|
||||
|
||||
val userJsonV300 = UserJsonV300(
|
||||
user_id = ExampleValue.userIdExample.value,
|
||||
email = ExampleValue.emailExample.value,
|
||||
provider_id = providerIdValueExample.value,
|
||||
provider = providerValueExample.value,
|
||||
username = usernameExample.value,
|
||||
entitlements = entitlementJSONs,
|
||||
views = Some(viewsJSON300)
|
||||
)
|
||||
|
||||
val userJsonV400 = UserJsonV400(
|
||||
user_id = ExampleValue.userIdExample.value,
|
||||
email = ExampleValue.emailExample.value,
|
||||
@ -1931,21 +1967,8 @@ object SwaggerDefinitionsJSON {
|
||||
provider = providerValueExample.value,
|
||||
username = usernameExample.value,
|
||||
entitlements = entitlementJSONs,
|
||||
views = None,
|
||||
agreements = None,
|
||||
is_deleted = false,
|
||||
last_marketing_agreement_signed_date = Some(DateWithDayExampleObject),
|
||||
is_locked = false
|
||||
)
|
||||
val userJsonWithAgreementsV400 = UserJsonV400(
|
||||
user_id = ExampleValue.userIdExample.value,
|
||||
email = ExampleValue.emailExample.value,
|
||||
provider_id = providerIdValueExample.value,
|
||||
provider = providerValueExample.value,
|
||||
username = usernameExample.value,
|
||||
entitlements = entitlementJSONs,
|
||||
views = None,
|
||||
agreements = Some(Nil),
|
||||
views = Some(viewsJSON300),
|
||||
agreements = Some(List(userAgreementJson)),
|
||||
is_deleted = false,
|
||||
last_marketing_agreement_signed_date = Some(DateWithDayExampleObject),
|
||||
is_locked = false
|
||||
@ -3246,7 +3269,7 @@ object SwaggerDefinitionsJSON {
|
||||
log_level = "Debug",
|
||||
remote_data_secret_matched = Some(true)
|
||||
)
|
||||
val metricsJSON = MetricsJSON(
|
||||
val metricsJSON = MetricsJsonV220(
|
||||
property = "String",
|
||||
value = "Mapper"
|
||||
)
|
||||
@ -4350,6 +4373,8 @@ object SwaggerDefinitionsJSON {
|
||||
views_available = List(viewBasicCommons),
|
||||
bank_id = bankIdExample.value
|
||||
)
|
||||
|
||||
val canGetCustomersJson = ApiRole.canGetCustomers
|
||||
|
||||
val cardAttributeCommons = CardAttributeCommons(
|
||||
bankId = Some(BankId(bankIdExample.value)),
|
||||
@ -4840,7 +4865,9 @@ object SwaggerDefinitionsJSON {
|
||||
successResponseBody = Option(json.parse(successResponseBodyExample.value))
|
||||
)
|
||||
|
||||
val jsonCodeTemplate = "code" -> URLEncoder.encode("""println("hello")""", "UTF-8")
|
||||
val jsonCodeTemplateJson = JsonCodeTemplateJson(
|
||||
URLEncoder.encode("""println("hello")""", "UTF-8")
|
||||
)
|
||||
|
||||
val supportedCurrenciesJson = SupportedCurrenciesJson(
|
||||
supportedCurrenciesExample.value
|
||||
|
||||
@ -18,6 +18,7 @@ import java.math.{BigDecimal => JBigDecimal}
|
||||
import code.api.AUOpenBanking.v1_0_0.ApiCollector
|
||||
import code.api.Constant
|
||||
import code.api.Polish.v2_1_1_1.OBP_PAPI_2_1_1_1
|
||||
import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON.{NotSupportedYet, notSupportedYet}
|
||||
import code.api.STET.v1_4.OBP_STET_1_4
|
||||
import code.api.UKOpenBanking.v2_0_0.OBP_UKOpenBanking_200
|
||||
import code.api.UKOpenBanking.v3_1_0.OBP_UKOpenBanking_310
|
||||
@ -152,7 +153,8 @@ object SwaggerJSONFactory extends MdcLoggable {
|
||||
case example: ListResult[_] =>
|
||||
val listResult = example.asInstanceOf[ListResult[List[_]]]
|
||||
Some(ResponseObjectSchemaJson(listResult))
|
||||
case s:scala.Product => Some(ResponseObjectSchemaJson(s"#/definitions/${s.getClass.getSimpleName}"))
|
||||
//TODO if value is List, need to be modified to Array later.
|
||||
case s:scala.Product if(!value.isInstanceOf[List[scala.Product]]) => Some(ResponseObjectSchemaJson(s"#/definitions/${s.getClass.getSimpleName}"))
|
||||
case _ => Some(ResponseObjectSchemaJson(s"#/definitions/NotSupportedYet"))
|
||||
}
|
||||
}
|
||||
@ -495,7 +497,7 @@ object SwaggerJSONFactory extends MdcLoggable {
|
||||
tags = rd.tags.map(_.tag),
|
||||
summary = rd.summary,
|
||||
description = PegdownOptions.convertPegdownToHtmlTweaked(rd.description.stripMargin).replaceAll("\n", ""),
|
||||
operationId =s"${rd.implementedInApiVersion.fullyQualifiedVersion }-${rd.partialFunctionName.toString }",
|
||||
operationId = s"${rd.partialFunctionName}",
|
||||
parameters ={
|
||||
val description = rd.exampleRequestBody match {
|
||||
case EmptyBody => ""
|
||||
@ -604,8 +606,7 @@ object SwaggerJSONFactory extends MdcLoggable {
|
||||
val paramValue = it._2
|
||||
|
||||
val exampleValue = paramValue match {
|
||||
case Some(v) => v
|
||||
case None => ""
|
||||
case Some(v) => v // Here it will get the value from Option/Box,
|
||||
case _ => paramValue
|
||||
}
|
||||
|
||||
@ -638,7 +639,7 @@ object SwaggerJSONFactory extends MdcLoggable {
|
||||
OBPEnumeration.getValuesByType(enumType).map(it => s""""$it"""").mkString(",")
|
||||
}
|
||||
def example = exampleValue match {
|
||||
case null => ""
|
||||
case null | None => ""
|
||||
case v: JValue => s""", "example": "${JsonUtils.toString(v)}" """
|
||||
case v => s""", "example": "$v" """
|
||||
}
|
||||
@ -651,6 +652,7 @@ object SwaggerJSONFactory extends MdcLoggable {
|
||||
|
||||
//Boolean - 4 kinds
|
||||
case _ if isAnyOfType[Boolean, JBool, XBoolean] => s""" {"type":"boolean" $example}"""
|
||||
case _ if exampleValue.isInstanceOf[Boolean] => s""" {"type":"boolean" $example}""" //TODO. Here need to be enhanced.
|
||||
case _ if isAnyOfType[Option[Boolean], Option[JBool], Option[XBoolean]] => s""" {"type":"boolean" $example}"""
|
||||
case _ if isAnyOfType[Coll[Boolean], Coll[JBool], Coll[XBoolean]] => s""" {"type":"array", "items":{"type": "boolean"}}"""
|
||||
case _ if isAnyOfType[Option[Coll[Boolean]],Option[Coll[JBool]],Option[Coll[XBoolean]]] => s""" {"type":"array", "items":{"type": "boolean"}}"""
|
||||
@ -706,6 +708,8 @@ object SwaggerJSONFactory extends MdcLoggable {
|
||||
val value = exampleValue match {
|
||||
case Some(v: Array[_]) if v.nonEmpty => v.head
|
||||
case Some(coll :Coll[_]) if coll.nonEmpty => coll.head
|
||||
case (v: Array[_]) if v.nonEmpty => v.head
|
||||
case (coll: Coll[_]) if coll.nonEmpty => coll.head
|
||||
case _ => null
|
||||
}
|
||||
s""" {"type": "array", "items":${buildSwaggerSchema(tp, value)}}"""
|
||||
@ -749,7 +753,11 @@ object SwaggerJSONFactory extends MdcLoggable {
|
||||
|
||||
val requiredFields = if (jFields.isEmpty) "[]" else jFields.map(_.name).map(name => s""" "$name" """).mkString("[", ",", "]")
|
||||
|
||||
s""" {"type":"object", "properties": { ${allFields.mkString(",")} }, "required": $requiredFields }"""
|
||||
if(requiredFields.equals("[]")) {
|
||||
s""" {"type":"object", "properties": { ${allFields.mkString(",")} } }"""
|
||||
} else{
|
||||
s""" {"type":"object", "properties": { ${allFields.mkString(",")} }, "required": $requiredFields }"""
|
||||
}
|
||||
|
||||
case _ if isTypeOf[JValue] =>
|
||||
Objects.nonNull(exampleValue)
|
||||
@ -824,9 +832,10 @@ object SwaggerJSONFactory extends MdcLoggable {
|
||||
*/
|
||||
private def getAllEntities(entities: List[AnyRef]) = {
|
||||
val notNullEntities = entities.filter(null !=)
|
||||
val notSupportYetEntity = entities.filter(_.getClass.getSimpleName.equals(NotSupportedYet.getClass.getSimpleName.replace("$","")))
|
||||
val existsEntityTypes: Set[universe.Type] = notNullEntities.map(ReflectUtils.getType).toSet
|
||||
|
||||
(notNullEntities ::: notNullEntities.flatMap(getNestedRefEntities(_, existsEntityTypes)))
|
||||
(notSupportYetEntity ::: notNullEntities ::: notNullEntities.flatMap(getNestedRefEntities(_, existsEntityTypes)))
|
||||
.distinctBy(_.getClass)
|
||||
}
|
||||
|
||||
@ -919,7 +928,8 @@ object SwaggerJSONFactory extends MdcLoggable {
|
||||
any => any != null && !excludeTypes.exists(_.isInstance(any))
|
||||
}
|
||||
|
||||
val docEntityExamples: List[AnyRef] = (resourceDocList.map(_.exampleRequestBody.asInstanceOf[AnyRef]) :::
|
||||
val docEntityExamples: List[AnyRef] = (List(notSupportedYet):::
|
||||
resourceDocList.map(_.exampleRequestBody.asInstanceOf[AnyRef]) :::
|
||||
resourceDocList.map(_.successResponseBody.asInstanceOf[AnyRef])
|
||||
).filter(predicate)
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import code.branches.Branches
|
||||
import code.customer.CustomerX
|
||||
import code.usercustomerlinks.UserCustomerLink
|
||||
import code.views.Views
|
||||
import com.github.dwickern.macros.NameOf.nameOf
|
||||
import com.openbankproject.commons.model._
|
||||
import com.openbankproject.commons.util.ApiVersion
|
||||
import net.liftweb.common.{Box, Full}
|
||||
@ -93,12 +94,12 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
|
||||
}
|
||||
|
||||
resourceDocs += ResourceDoc(
|
||||
getCustomerMessages,
|
||||
getCustomersMessages,
|
||||
apiVersion,
|
||||
"getCustomerMessages",
|
||||
"getCustomersMessages",
|
||||
"GET",
|
||||
"/banks/BANK_ID/customer/messages",
|
||||
"Get Customer Messages for a Customer",
|
||||
"Get Customer Messages for all Customers",
|
||||
"""Get messages for the logged in customer
|
||||
|Messages sent to the currently authenticated user.
|
||||
|
|
||||
@ -108,7 +109,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
|
||||
List(UserNotLoggedIn, UnknownError),
|
||||
List(apiTagMessage, apiTagCustomer))
|
||||
|
||||
lazy val getCustomerMessages : OBPEndpoint = {
|
||||
lazy val getCustomersMessages : OBPEndpoint = {
|
||||
case "banks" :: BankId(bankId) :: "customer" :: "messages" :: Nil JsonGet _ => {
|
||||
cc =>{
|
||||
for {
|
||||
@ -128,7 +129,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
|
||||
resourceDocs += ResourceDoc(
|
||||
addCustomerMessage,
|
||||
apiVersion,
|
||||
"createCustomerMessage",
|
||||
nameOf(addCustomerMessage),
|
||||
"POST",
|
||||
"/banks/BANK_ID/customer/CUSTOMER_ID/messages",
|
||||
"Create Customer Message",
|
||||
|
||||
@ -97,7 +97,7 @@ object OBPAPI1_4_0 extends OBPRestHelper with APIMethods140 with MdcLoggable wit
|
||||
val endpointsOf1_4_0 = List(
|
||||
Implementations1_4_0.getCustomer,
|
||||
Implementations1_4_0.addCustomer,
|
||||
Implementations1_4_0.getCustomerMessages,
|
||||
Implementations1_4_0.getCustomersMessages,
|
||||
Implementations1_4_0.addCustomerMessage,
|
||||
Implementations1_4_0.getBranches,
|
||||
Implementations1_4_0.getAtms,
|
||||
|
||||
@ -127,7 +127,7 @@ object OBPAPI2_0_0 extends OBPRestHelper with APIMethods130 with APIMethods140 w
|
||||
// Possible Endpoints 2.0.0 (less info about the views)
|
||||
val endpointsOf1_4_0 = List( Implementations1_4_0.getCustomer,
|
||||
// Now in 2.0.0 Implementations1_4_0.addCustomer,
|
||||
Implementations1_4_0.getCustomerMessages,
|
||||
Implementations1_4_0.getCustomersMessages,
|
||||
Implementations1_4_0.addCustomerMessage,
|
||||
Implementations1_4_0.getBranches,
|
||||
Implementations1_4_0.getAtms,
|
||||
|
||||
@ -120,7 +120,7 @@ object OBPAPI2_1_0 extends OBPRestHelper with APIMethods130 with APIMethods140 w
|
||||
|
||||
|
||||
// Possible Endpoints 1.4.0
|
||||
val endpointsOf1_4_0 = Implementations1_4_0.getCustomerMessages ::
|
||||
val endpointsOf1_4_0 = Implementations1_4_0.getCustomersMessages ::
|
||||
Implementations1_4_0.addCustomerMessage ::
|
||||
Implementations1_4_0.getBranches ::
|
||||
Implementations1_4_0.getAtms ::
|
||||
|
||||
@ -273,9 +273,9 @@ case class CreateAccountJSONV220(
|
||||
case class CachedFunctionJSON(function_name: String, ttl_in_seconds: Int)
|
||||
case class PortJSON(property: String, value: String)
|
||||
case class AkkaJSON(ports: List[PortJSON], log_level: String, remote_data_secret_matched: Option[Boolean])
|
||||
case class MetricsJSON(property: String, value: String)
|
||||
case class MetricsJsonV220(property: String, value: String)
|
||||
case class WarehouseJSON(property: String, value: String)
|
||||
case class ElasticSearchJSON(metrics: List[MetricsJSON], warehouse: List[WarehouseJSON])
|
||||
case class ElasticSearchJSON(metrics: List[MetricsJsonV220], warehouse: List[WarehouseJSON])
|
||||
case class ScopesJSON(require_scopes_for_all_roles: Boolean, require_scopes_for_listed_roles: List[String])
|
||||
case class ConfigurationJSON(akka: AkkaJSON, elastic_search: ElasticSearchJSON, cache: List[CachedFunctionJSON], scopes: ScopesJSON)
|
||||
|
||||
@ -797,8 +797,8 @@ object JSONFactory220 {
|
||||
val akka = AkkaJSON(akkaPorts, ObpActorConfig.akka_loglevel, APIUtil.akkaSanityCheck())
|
||||
val cache = f1::f2::f3::f4::f5::f6::f7::f8::Nil
|
||||
|
||||
val metrics = MetricsJSON("es.metrics.port.tcp", APIUtil.getPropsValue("es.metrics.port.tcp", "9300")) ::
|
||||
MetricsJSON("es.metrics.port.http", APIUtil.getPropsValue("es.metrics.port.tcp", "9200")) ::
|
||||
val metrics = MetricsJsonV220("es.metrics.port.tcp", APIUtil.getPropsValue("es.metrics.port.tcp", "9300")) ::
|
||||
MetricsJsonV220("es.metrics.port.http", APIUtil.getPropsValue("es.metrics.port.tcp", "9200")) ::
|
||||
Nil
|
||||
val warehouse = WarehouseJSON("es.warehouse.port.tcp", APIUtil.getPropsValue("es.warehouse.port.tcp", "9300")) ::
|
||||
WarehouseJSON("es.warehouse.port.http", APIUtil.getPropsValue("es.warehouse.port.http", "9200")) ::
|
||||
|
||||
@ -94,7 +94,7 @@ object OBPAPI2_2_0 extends OBPRestHelper with APIMethods130 with APIMethods140 w
|
||||
|
||||
|
||||
// Possible Endpoints 1.4.0
|
||||
val endpointsOf1_4_0 = Implementations1_4_0.getCustomerMessages ::
|
||||
val endpointsOf1_4_0 = Implementations1_4_0.getCustomersMessages ::
|
||||
Implementations1_4_0.addCustomerMessage ::
|
||||
Implementations1_4_0.getBranches ::
|
||||
Implementations1_4_0.getAtms ::
|
||||
|
||||
@ -1591,7 +1591,7 @@ trait APIMethods300 {
|
||||
|${authenticationRequiredMessage(true)}
|
||||
""".stripMargin,
|
||||
EmptyBody,
|
||||
userJsonV200,
|
||||
userJsonV300,
|
||||
List(UserNotLoggedIn, UnknownError),
|
||||
List(apiTagUser, apiTagNewStyle))
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ object OBPAPI3_0_0 extends OBPRestHelper with APIMethods130 with APIMethods140 w
|
||||
|
||||
|
||||
// Possible Endpoints from 1.4.0
|
||||
val endpointsOf1_4_0 = Implementations1_4_0.getCustomerMessages ::
|
||||
val endpointsOf1_4_0 = Implementations1_4_0.getCustomersMessages ::
|
||||
Implementations1_4_0.addCustomerMessage ::
|
||||
// Implementations1_4_0.getBranches :: //now in V300
|
||||
// Implementations1_4_0.getAtms :: //now in V300
|
||||
|
||||
@ -130,7 +130,7 @@ object OBPAPI3_1_0 extends OBPRestHelper with APIMethods130 with APIMethods140 w
|
||||
|
||||
|
||||
// Possible Endpoints from 1.4.0
|
||||
val endpointsOf1_4_0 = Implementations1_4_0.getCustomerMessages ::
|
||||
val endpointsOf1_4_0 = Implementations1_4_0.getCustomersMessages ::
|
||||
Implementations1_4_0.addCustomerMessage ::
|
||||
// Implementations1_4_0.getBranches :: //now in V300
|
||||
// Implementations1_4_0.getAtms :: //now in V300
|
||||
|
||||
@ -3615,7 +3615,7 @@ trait APIMethods400 {
|
||||
|
|
||||
""".stripMargin,
|
||||
EmptyBody,
|
||||
userJsonWithAgreementsV400,
|
||||
userJsonV400,
|
||||
List(UserNotLoggedIn, UserHasMissingRoles, UserNotFoundById, UnknownError),
|
||||
List(apiTagUser, apiTagNewStyle),
|
||||
Some(List(canGetAnyUser)))
|
||||
@ -8891,7 +8891,7 @@ trait APIMethods400 {
|
||||
EmptyBody,
|
||||
ListResult(
|
||||
"scanned_api_versions",
|
||||
List(ApiVersion.v3_1_0)
|
||||
List(Extraction.decompose(ApiVersion.v3_1_0))
|
||||
),
|
||||
List(
|
||||
UnknownError
|
||||
@ -10600,7 +10600,7 @@ trait APIMethods400 {
|
||||
|auto compilation and debug
|
||||
|""",
|
||||
jsonResourceDocFragment,
|
||||
jsonCodeTemplate,
|
||||
jsonCodeTemplateJson,
|
||||
List(
|
||||
$UserNotLoggedIn,
|
||||
InvalidJsonFormat,
|
||||
@ -10633,7 +10633,7 @@ trait APIMethods400 {
|
||||
code = DynamicEndpointCodeGenerator.buildTemplate(resourceDocFragment)
|
||||
|
||||
} yield {
|
||||
("code" -> URLEncoder.encode(code, "UTF-8"), HttpCode.`201`(cc.callContext))
|
||||
(JsonCodeTemplateJson(URLEncoder.encode(code, "UTF-8")), HttpCode.`201`(cc.callContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11762,7 +11762,7 @@ trait APIMethods400 {
|
||||
InvalidJsonFormat,
|
||||
UnknownError
|
||||
),
|
||||
List(apiTagApi, apiTagApi, apiTagNewStyle),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canCreateSystemLevelEndpointTag)))
|
||||
lazy val createSystemLevelEndpointTag: OBPEndpoint = {
|
||||
case "management" :: "endpoints" :: operationId :: "tags" :: Nil JsonPost json -> _ => {
|
||||
@ -11803,7 +11803,7 @@ trait APIMethods400 {
|
||||
InvalidJsonFormat,
|
||||
UnknownError
|
||||
),
|
||||
List(apiTagApi, apiTagApi, apiTagNewStyle),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canUpdateSystemLevelEndpointTag)))
|
||||
lazy val updateSystemLevelEndpointTag: OBPEndpoint = {
|
||||
case "management" :: "endpoints" :: operationId :: "tags" :: endpointTagId :: Nil JsonPut json -> _ => {
|
||||
@ -11843,7 +11843,7 @@ trait APIMethods400 {
|
||||
UserHasMissingRoles,
|
||||
UnknownError
|
||||
),
|
||||
List(apiTagApi, apiTagApi, apiTagNewStyle),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canGetSystemLevelEndpointTag)))
|
||||
lazy val getSystemLevelEndpointTags: OBPEndpoint = {
|
||||
case "management" :: "endpoints" :: operationId :: "tags" :: Nil JsonGet _ => {
|
||||
@ -11875,7 +11875,7 @@ trait APIMethods400 {
|
||||
UserHasMissingRoles,
|
||||
UnknownError
|
||||
),
|
||||
List(apiTagApi, apiTagApi, apiTagNewStyle),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canDeleteSystemLevelEndpointTag)))
|
||||
lazy val deleteSystemLevelEndpointTag: OBPEndpoint = {
|
||||
case "management" :: "endpoints" :: operationId :: "tags" :: endpointTagId :: Nil JsonDelete _ => {
|
||||
@ -11907,7 +11907,7 @@ trait APIMethods400 {
|
||||
InvalidJsonFormat,
|
||||
UnknownError
|
||||
),
|
||||
List(apiTagApi, apiTagApi, apiTagNewStyle),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canCreateBankLevelEndpointTag)))
|
||||
lazy val createBankLevelEndpointTag: OBPEndpoint = {
|
||||
case "management" :: "banks" :: bankId :: "endpoints" :: operationId :: "tags" :: Nil JsonPost json -> _ => {
|
||||
@ -11950,7 +11950,7 @@ trait APIMethods400 {
|
||||
InvalidJsonFormat,
|
||||
UnknownError
|
||||
),
|
||||
List(apiTagApi, apiTagApi, apiTagNewStyle),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canUpdateBankLevelEndpointTag)))
|
||||
lazy val updateBankLevelEndpointTag: OBPEndpoint = {
|
||||
case "management":: "banks" :: bankId :: "endpoints" :: operationId :: "tags" :: endpointTagId :: Nil JsonPut json -> _ => {
|
||||
@ -11992,7 +11992,7 @@ trait APIMethods400 {
|
||||
UserHasMissingRoles,
|
||||
UnknownError
|
||||
),
|
||||
List(apiTagApi, apiTagApi, apiTagNewStyle),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canGetBankLevelEndpointTag)))
|
||||
lazy val getBankLevelEndpointTags: OBPEndpoint = {
|
||||
case "management":: "banks" :: bankId :: "endpoints" :: operationId :: "tags" :: Nil JsonGet _ => {
|
||||
@ -12026,7 +12026,7 @@ trait APIMethods400 {
|
||||
UserHasMissingRoles,
|
||||
UnknownError
|
||||
),
|
||||
List(apiTagApi, apiTagApi, apiTagNewStyle),
|
||||
List(apiTagApi, apiTagNewStyle),
|
||||
Some(List(canDeleteBankLevelEndpointTag)))
|
||||
lazy val deleteBankLevelEndpointTag: OBPEndpoint = {
|
||||
case "management":: "banks" :: bankId :: "endpoints" :: operationId :: "tags" :: endpointTagId :: Nil JsonDelete _ => {
|
||||
|
||||
@ -1083,6 +1083,10 @@ case class CustomerMessageJsonV400(
|
||||
from_person: String
|
||||
)
|
||||
|
||||
case class JsonCodeTemplateJson(
|
||||
code: String
|
||||
)
|
||||
|
||||
object JSONFactory400 {
|
||||
|
||||
def createCustomerMessageJson(cMessage : CustomerMessage) : CustomerMessageJsonV400 = {
|
||||
|
||||
@ -1342,7 +1342,7 @@ trait APIMethods500 {
|
||||
for {
|
||||
(Full(u), callContext) <- SS.user
|
||||
_ <- NewStyle.function.hasAtLeastOneEntitlement(failMsg = createProductEntitlementsRequiredText)(bankId.value, u.userId, createProductEntitlements, callContext)
|
||||
failMsg = s"$InvalidJsonFormat The Json body should be the $PutProductJsonV400 "
|
||||
failMsg = s"$InvalidJsonFormat The Json body should be the $PutProductJsonV500 "
|
||||
product <- NewStyle.function.tryons(failMsg, 400, callContext) {
|
||||
json.extract[PutProductJsonV500]
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -7,6 +7,8 @@ import code.api.v2_2_0.OBPAPI2_2_0
|
||||
import code.api.v3_0_0.OBPAPI3_0_0
|
||||
import code.api.v3_1_0.OBPAPI3_1_0
|
||||
import code.api.v4_0_0.OBPAPI4_0_0
|
||||
import code.api.v5_0_0.OBPAPI5_0_0
|
||||
import code.api.v5_1_0.OBPAPI5_1_0
|
||||
import code.util.Helper.MdcLoggable
|
||||
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
@ -53,7 +55,14 @@ class SwaggerFactoryUnitTest extends V140ServerSetup with MdcLoggable {
|
||||
}
|
||||
feature("Test all V300, V220 and V210, exampleRequestBodies and successResponseBodies and all the case classes in SwaggerDefinitionsJSON") {
|
||||
scenario("Test all the case classes") {
|
||||
val resourceDocList: ArrayBuffer[ResourceDoc] = OBPAPI3_1_0.allResourceDocs ++ OBPAPI3_0_0.allResourceDocs ++ OBPAPI2_2_0.allResourceDocs ++ OBPAPI2_1_0.allResourceDocs
|
||||
val resourceDocList: ArrayBuffer[ResourceDoc] =
|
||||
OBPAPI5_1_0.allResourceDocs ++
|
||||
OBPAPI5_0_0.allResourceDocs ++
|
||||
OBPAPI4_0_0.allResourceDocs ++
|
||||
OBPAPI3_1_0.allResourceDocs ++
|
||||
OBPAPI3_0_0.allResourceDocs ++
|
||||
OBPAPI2_2_0.allResourceDocs ++
|
||||
OBPAPI2_1_0.allResourceDocs
|
||||
|
||||
//Translate every entity(JSON Case Class) in a list to appropriate swagger format
|
||||
val listOfExampleRequestBodyDefinition =
|
||||
@ -75,15 +84,12 @@ class SwaggerFactoryUnitTest extends V140ServerSetup with MdcLoggable {
|
||||
val allStrings = listOfExampleRequestBodyDefinition ++ listOfSuccessRequestBodyDefinition ++ listNestedMissingDefinition
|
||||
//All of the following are invalid value in Swagger, if any of them exist,
|
||||
//need check how you create the case class object in SwaggerDefinitionsJSON.json.
|
||||
allStrings.toString() should not include ("$colon") // This happened when use the primitive types. eg: val b = List("tesobe"), the List can not be find for now.
|
||||
allStrings.toString() should not include ("Nil$")
|
||||
allStrings.toString() should not include ("JArray")
|
||||
allStrings.toString() should not include ("JBool")
|
||||
allStrings.toString() should not include ("JInt")
|
||||
allStrings.toString() should not include ("JNothing")
|
||||
allStrings.toString() should not include ("JNull")
|
||||
allStrings.toString() should not include ("JObject")
|
||||
allStrings.toString() should not include ("JString")
|
||||
allStrings.toString() should not include ("None$")
|
||||
allStrings.toString() should not include ("definitions/scala.Some")
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package code.api.v4_0_0
|
||||
|
||||
import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON.jsonCodeTemplate
|
||||
import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON.jsonCodeTemplateJson
|
||||
import code.api.util.APIUtil.OAuth._
|
||||
import code.api.util.ApiRole._
|
||||
import code.api.util.ErrorMessages.{UserNotLoggedIn, _}
|
||||
@ -30,7 +30,7 @@ class EndpointMappingBankLevelTest extends V400ServerSetup {
|
||||
object ApiEndpoint5 extends Tag(nameOf(Implementations4_0_0.deleteBankLevelEndpointMapping))
|
||||
|
||||
val rightEntity = endpointMappingRequestBodyExample
|
||||
val wrongEntity = jsonCodeTemplate
|
||||
val wrongEntity = jsonCodeTemplateJson
|
||||
|
||||
feature("Add a EndpointMapping v4.0.0- Unauthorized access") {
|
||||
scenario("We will call the endpoint without user credentials", ApiEndpoint1, VersionOfApi) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package code.api.v4_0_0
|
||||
|
||||
import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON.jsonCodeTemplate
|
||||
import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON.jsonCodeTemplateJson
|
||||
import code.api.util.APIUtil.OAuth._
|
||||
import code.api.util.ApiRole.{CanCreateEndpointMapping, _}
|
||||
import code.api.util.ErrorMessages.{UserNotLoggedIn, _}
|
||||
@ -30,7 +30,7 @@ class EndpointMappingTest extends V400ServerSetup {
|
||||
object ApiEndpoint5 extends Tag(nameOf(Implementations4_0_0.deleteEndpointMapping))
|
||||
|
||||
val rightEntity = endpointMappingRequestBodyExample
|
||||
val wrongEntity = jsonCodeTemplate
|
||||
val wrongEntity = jsonCodeTemplateJson
|
||||
|
||||
feature("Add a EndpointMapping v4.0.0- Unauthorized access") {
|
||||
scenario("We will call the endpoint without user credentials", ApiEndpoint1, VersionOfApi) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user