mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 13:07:02 +00:00
feature/Added OBPv510
This commit is contained in:
parent
81283c5830
commit
711dc693bf
@ -410,6 +410,7 @@ class Boot extends MdcLoggable {
|
||||
enableVersionIfAllowed(ApiVersion.v3_1_0)
|
||||
enableVersionIfAllowed(ApiVersion.v4_0_0)
|
||||
enableVersionIfAllowed(ApiVersion.v5_0_0)
|
||||
enableVersionIfAllowed(ApiVersion.v5_1_0)
|
||||
enableVersionIfAllowed(ApiVersion.b1)
|
||||
enableVersionIfAllowed(ApiVersion.`dynamic-endpoint`)
|
||||
enableVersionIfAllowed(ApiVersion.`dynamic-entity`)
|
||||
|
||||
@ -38,6 +38,7 @@ import code.api.v3_0_0.APIMethods300
|
||||
import code.api.v3_1_0.APIMethods310
|
||||
import code.api.v4_0_0.{APIMethods400, OBPAPI4_0_0}
|
||||
import code.api.v5_0_0.OBPAPI5_0_0
|
||||
import code.api.v5_1_0.OBPAPI5_1_0
|
||||
import code.loginattempts.LoginAttempt
|
||||
import code.model.dataAccess.AuthUser
|
||||
import code.util.Helper.MdcLoggable
|
||||
@ -666,7 +667,7 @@ trait OBPRestHelper extends RestHelper with MdcLoggable {
|
||||
autoValidateAll: Boolean = false): Unit = {
|
||||
|
||||
def isAutoValidate(doc: ResourceDoc): Boolean = { //note: only support v5.0.0 and v4.0.0 at the moment.
|
||||
doc.isValidateEnabled || (autoValidateAll && !doc.isValidateDisabled && List(OBPAPI5_0_0.version,OBPAPI4_0_0.version).contains(doc.implementedInApiVersion))
|
||||
doc.isValidateEnabled || (autoValidateAll && !doc.isValidateDisabled && List(OBPAPI5_1_0.version,OBPAPI5_0_0.version,OBPAPI4_0_0.version).contains(doc.implementedInApiVersion))
|
||||
}
|
||||
|
||||
for(route <- routes) {
|
||||
|
||||
@ -38,6 +38,7 @@ import net.liftweb.util.Props
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import code.api.util.NewStyle.HttpCode
|
||||
import code.api.v5_0_0.OBPAPI5_0_0
|
||||
import code.api.v5_1_0.OBPAPI5_1_0
|
||||
import code.util.Helper
|
||||
|
||||
import scala.collection.immutable.{List, Nil}
|
||||
@ -120,6 +121,7 @@ trait ResourceDocsAPIMethods extends MdcLoggable with APIMethods220 with APIMeth
|
||||
|
||||
val resourceDocs = requestedApiVersion match {
|
||||
case ApiVersion.`b1` => OBP_APIBuilder.allResourceDocs
|
||||
case ApiVersion.v5_1_0 => OBPAPI5_1_0.allResourceDocs
|
||||
case ApiVersion.v5_0_0 => OBPAPI5_0_0.allResourceDocs
|
||||
case ApiVersion.v4_0_0 => OBPAPI4_0_0.allResourceDocs
|
||||
case ApiVersion.v3_1_0 => OBPAPI3_1_0.allResourceDocs
|
||||
@ -138,6 +140,7 @@ trait ResourceDocsAPIMethods extends MdcLoggable with APIMethods220 with APIMeth
|
||||
|
||||
val versionRoutes = requestedApiVersion match {
|
||||
case ApiVersion.`b1` => OBP_APIBuilder.routes
|
||||
case ApiVersion.v5_1_0 => OBPAPI5_1_0.routes
|
||||
case ApiVersion.v5_0_0 => OBPAPI5_0_0.routes
|
||||
case ApiVersion.v4_0_0 => OBPAPI4_0_0.routes
|
||||
case ApiVersion.v3_1_0 => OBPAPI3_1_0.routes
|
||||
|
||||
@ -2488,6 +2488,7 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{
|
||||
case ApiVersion.v3_1_0 => LiftRules.statelessDispatch.append(v3_1_0.OBPAPI3_1_0)
|
||||
case ApiVersion.v4_0_0 => LiftRules.statelessDispatch.append(v4_0_0.OBPAPI4_0_0)
|
||||
case ApiVersion.v5_0_0 => LiftRules.statelessDispatch.append(v5_0_0.OBPAPI5_0_0)
|
||||
case ApiVersion.v5_1_0 => LiftRules.statelessDispatch.append(v5_1_0.OBPAPI5_1_0)
|
||||
case ApiVersion.`dynamic-endpoint` => LiftRules.statelessDispatch.append(OBPAPIDynamicEndpoint)
|
||||
case ApiVersion.`dynamic-entity` => LiftRules.statelessDispatch.append(OBPAPIDynamicEntity)
|
||||
case ApiVersion.`b1` => LiftRules.statelessDispatch.append(OBP_APIBuilder)
|
||||
|
||||
@ -17,6 +17,7 @@ object ApiVersionUtils {
|
||||
v3_1_0 ::
|
||||
v4_0_0 ::
|
||||
v5_0_0 ::
|
||||
v5_1_0 ::
|
||||
`dynamic-endpoint` ::
|
||||
`dynamic-entity` ::
|
||||
b1::
|
||||
@ -38,6 +39,7 @@ object ApiVersionUtils {
|
||||
case v3_1_0.fullyQualifiedVersion | v3_1_0.apiShortVersion => v3_1_0
|
||||
case v4_0_0.fullyQualifiedVersion | v4_0_0.apiShortVersion => v4_0_0
|
||||
case v5_0_0.fullyQualifiedVersion | v5_0_0.apiShortVersion => v5_0_0
|
||||
case v5_1_0.fullyQualifiedVersion | v5_1_0.apiShortVersion => v5_1_0
|
||||
case `dynamic-endpoint`.fullyQualifiedVersion | `dynamic-endpoint`.apiShortVersion => `dynamic-endpoint`
|
||||
case `dynamic-entity`.fullyQualifiedVersion | `dynamic-entity`.apiShortVersion => `dynamic-entity`
|
||||
case b1.fullyQualifiedVersion | b1.apiShortVersion => b1
|
||||
|
||||
38
obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala
Normal file
38
obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala
Normal file
@ -0,0 +1,38 @@
|
||||
package code.api.v5_1_0
|
||||
|
||||
|
||||
import code.api.util.APIUtil._
|
||||
|
||||
import code.transactionrequests.TransactionRequests.TransactionRequestTypes.{apply => _}
|
||||
import com.github.dwickern.macros.NameOf.nameOf
|
||||
import com.openbankproject.commons.model.BankId
|
||||
import com.openbankproject.commons.util.ApiVersion
|
||||
import net.liftweb.http.rest.RestHelper
|
||||
import com.openbankproject.commons.ExecutionContext.Implicits.global
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
||||
|
||||
trait APIMethods510 {
|
||||
self: RestHelper =>
|
||||
|
||||
val Implementations5_1_0 = new Implementations510()
|
||||
|
||||
class Implementations510 {
|
||||
|
||||
val implementedInApiVersion = ApiVersion.v5_1_0
|
||||
|
||||
private val staticResourceDocs = ArrayBuffer[ResourceDoc]()
|
||||
def resourceDocs = staticResourceDocs
|
||||
|
||||
val apiRelations = ArrayBuffer[ApiRelation]()
|
||||
val codeContext = CodeContext(staticResourceDocs, apiRelations)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
object APIMethods510 extends RestHelper with APIMethods510 {
|
||||
lazy val newStyleEndpoints: List[(String, String)] = Implementations5_1_0.resourceDocs.map {
|
||||
rd => (rd.partialFunctionName, rd.implementedInApiVersion.toString())
|
||||
}.toList
|
||||
}
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Open Bank Project - API
|
||||
* Copyright (C) 2011-2019, TESOBE GmbH
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* *
|
||||
* Email: contact@tesobe.com
|
||||
* TESOBE GmbH
|
||||
* Osloerstrasse 16/17
|
||||
* Berlin 13359, Germany
|
||||
* *
|
||||
* This product includes software developed at
|
||||
* TESOBE (http://www.tesobe.com/)
|
||||
*
|
||||
*/
|
||||
package code.api.v5_1_0
|
||||
|
||||
|
||||
object JSONFactory510 {
|
||||
|
||||
|
||||
}
|
||||
|
||||
109
obp-api/src/main/scala/code/api/v5_1_0/OBPAPI5_1_0.scala
Normal file
109
obp-api/src/main/scala/code/api/v5_1_0/OBPAPI5_1_0.scala
Normal file
@ -0,0 +1,109 @@
|
||||
/**
|
||||
Open Bank Project - API
|
||||
Copyright (C) 2011-2019, TESOBE GmbH.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Email: contact@tesobe.com
|
||||
TESOBE GmbH.
|
||||
Osloer Strasse 16/17
|
||||
Berlin 13359, Germany
|
||||
|
||||
This product includes software developed at
|
||||
TESOBE (http://www.tesobe.com/)
|
||||
|
||||
*/
|
||||
package code.api.v5_1_0
|
||||
|
||||
import code.api.OBPRestHelper
|
||||
import code.api.util.APIUtil.{OBPEndpoint, getAllowedEndpoints}
|
||||
import code.api.util.{APIUtil, VersionedOBPApis}
|
||||
import code.api.v1_3_0.APIMethods130
|
||||
import code.api.v1_4_0.APIMethods140
|
||||
import code.api.v2_0_0.APIMethods200
|
||||
import code.api.v2_1_0.APIMethods210
|
||||
import code.api.v2_2_0.APIMethods220
|
||||
import code.api.v3_0_0.APIMethods300
|
||||
import code.api.v3_0_0.custom.CustomAPIMethods300
|
||||
import code.api.v3_1_0.{APIMethods310}
|
||||
import code.api.v4_0_0.{APIMethods400}
|
||||
import code.api.v5_0_0.{APIMethods500, OBPAPI5_0_0}
|
||||
import code.util.Helper.MdcLoggable
|
||||
import com.openbankproject.commons.util.ApiVersion
|
||||
import net.liftweb.common.{Box, Full}
|
||||
import net.liftweb.http.{LiftResponse, PlainTextResponse}
|
||||
import org.apache.http.HttpStatus
|
||||
|
||||
/*
|
||||
This file defines which endpoints from all the versions are available in v5.0.0
|
||||
*/
|
||||
object OBPAPI5_1_0 extends OBPRestHelper
|
||||
with APIMethods130
|
||||
with APIMethods140
|
||||
with APIMethods200
|
||||
with APIMethods210
|
||||
with APIMethods220
|
||||
with APIMethods300
|
||||
with CustomAPIMethods300
|
||||
with APIMethods310
|
||||
with APIMethods400
|
||||
with APIMethods500
|
||||
with APIMethods510
|
||||
with MdcLoggable
|
||||
with VersionedOBPApis{
|
||||
|
||||
val version : ApiVersion = ApiVersion.v5_1_0
|
||||
|
||||
val versionStatus = "BLEEDING-EDGE" // TODO this should be a property of ApiVersion.
|
||||
|
||||
// Possible Endpoints from 5.1.0, exclude one endpoint use - method,exclude multiple endpoints use -- method,
|
||||
// e.g getEndpoints(Implementations5_0_0) -- List(Implementations5_0_0.genericEndpoint, Implementations5_0_0.root)
|
||||
val endpointsOf5_1_0 = getEndpoints(Implementations5_1_0)
|
||||
|
||||
// if old version ResourceDoc objects have the same name endpoint with new version, omit old version ResourceDoc.
|
||||
def allResourceDocs = collectResourceDocs(
|
||||
OBPAPI5_0_0.allResourceDocs,
|
||||
Implementations5_1_0.resourceDocs
|
||||
)
|
||||
|
||||
// all endpoints
|
||||
private val endpoints: List[OBPEndpoint] = OBPAPI5_0_0.routes ++ endpointsOf5_1_0
|
||||
|
||||
// Filter the possible endpoints by the disabled / enabled Props settings and add them together
|
||||
val routes : List[OBPEndpoint] = getAllowedEndpoints(endpoints, allResourceDocs)
|
||||
|
||||
// register v5.1.0 apis first, Make them available for use!
|
||||
registerRoutes(routes, allResourceDocs, apiPrefix, true)
|
||||
|
||||
|
||||
logger.info(s"version $version has been run! There are ${routes.length} routes, ${allResourceDocs.length} allResourceDocs.")
|
||||
|
||||
// specified response for OPTIONS request.
|
||||
private val corsResponse: Box[LiftResponse] = Full{
|
||||
val corsHeaders = List(
|
||||
"Access-Control-Allow-Origin" -> "*",
|
||||
"Access-Control-Allow-Methods" -> "GET, POST, OPTIONS, PUT, PATCH, DELETE",
|
||||
"Access-Control-Allow-Headers" -> "*",
|
||||
"Access-Control-Allow-Credentials" -> "true",
|
||||
"Access-Control-Max-Age" -> "1728000" //Tell client that this pre-flight info is valid for 20 days
|
||||
)
|
||||
PlainTextResponse("", corsHeaders, HttpStatus.SC_NO_CONTENT)
|
||||
}
|
||||
/*
|
||||
* process OPTIONS http request, just return no content and status is 204
|
||||
*/
|
||||
this.serve({
|
||||
case req if req.requestType.method == "OPTIONS" => corsResponse
|
||||
})
|
||||
}
|
||||
@ -23,6 +23,7 @@ object ApiShortVersions extends Enumeration {
|
||||
val `v3.1.0` = Value("v3.1.0")
|
||||
val `v4.0.0` = Value("v4.0.0")
|
||||
val `v5.0.0` = Value("v5.0.0")
|
||||
val `v5.1.0` = Value("v5.1.0")
|
||||
val b1 = Value
|
||||
val `dynamic-endpoint` = Value("dynamic-endpoint")
|
||||
val `dynamic-entity` = Value("dynamic-entity")
|
||||
@ -108,6 +109,7 @@ object ApiVersion {
|
||||
val v3_1_0 = ScannedApiVersion(urlPrefix,ApiStandards.obp.toString,ApiShortVersions.`v3.1.0`.toString)
|
||||
val v4_0_0 = ScannedApiVersion(urlPrefix,ApiStandards.obp.toString,ApiShortVersions.`v4.0.0`.toString)
|
||||
val v5_0_0 = ScannedApiVersion(urlPrefix,ApiStandards.obp.toString,ApiShortVersions.`v5.0.0`.toString)
|
||||
val v5_1_0 = ScannedApiVersion(urlPrefix,ApiStandards.obp.toString,ApiShortVersions.`v5.1.0`.toString)
|
||||
val `dynamic-endpoint` = ScannedApiVersion(urlPrefix,ApiStandards.obp.toString,ApiShortVersions.`dynamic-endpoint`.toString)
|
||||
val `dynamic-entity` = ScannedApiVersion(urlPrefix,ApiStandards.obp.toString,ApiShortVersions.`dynamic-entity`.toString)
|
||||
|
||||
@ -126,6 +128,7 @@ object ApiVersion {
|
||||
v3_1_0 ::
|
||||
v4_0_0 ::
|
||||
v5_0_0 ::
|
||||
v5_1_0 ::
|
||||
b1 ::
|
||||
`dynamic-endpoint` ::
|
||||
`dynamic-entity`::
|
||||
|
||||
Loading…
Reference in New Issue
Block a user