bugfix/fix '/obp/v5.0.0/root' to show correct API version

This commit is contained in:
hongwei 2023-01-27 10:37:23 +01:00
parent 9a34c8763c
commit 0d7b6fa57b
10 changed files with 19 additions and 19 deletions

View File

@ -131,7 +131,7 @@ object ResourceDocs300 extends OBPRestHelper with ResourceDocsAPIMethods with Md
object ResourceDocs510 extends OBPRestHelper with ResourceDocsAPIMethods with MdcLoggable {
val version: ApiVersion = ApiVersion.v5_1_0
val versionStatus = ApiVersionStatus.`BLEEDING-EDGE`.toString
val versionStatus = ApiVersionStatus.BLEEDING_EDGE.toString
val routes = List(
ImplementationsResourceDocs.getResourceDocsObpV400,
ImplementationsResourceDocs.getResourceDocsSwagger,

View File

@ -45,7 +45,7 @@ object OBPAPIDynamicEndpoint extends OBPRestHelper with MdcLoggable with Version
val version : ApiVersion = ApiVersion.`dynamic-endpoint`
val versionStatus = ApiVersionStatus.`BLEEDING-EDGE`.toString
val versionStatus = ApiVersionStatus.BLEEDING_EDGE.toString
// if old version ResourceDoc objects have the same name endpoint with new version, omit old version ResourceDoc.
def allResourceDocs = collectResourceDocs(ImplementationsDynamicEndpoint.resourceDocs)

View File

@ -45,7 +45,7 @@ object OBPAPIDynamicEntity extends OBPRestHelper with MdcLoggable with Versioned
val version : ApiVersion = ApiVersion.`dynamic-entity`
val versionStatus = ApiVersionStatus.`BLEEDING-EDGE`.toString
val versionStatus = ApiVersionStatus.BLEEDING_EDGE.toString
// if old version ResourceDoc objects have the same name endpoint with new version, omit old version ResourceDoc.
def allResourceDocs = collectResourceDocs(ImplementationsDynamicEntity.resourceDocs)

View File

@ -2637,8 +2637,7 @@ trait APIMethods400 {
private def getApiInfoJSON() = {
val (apiVersion, apiVersionStatus) = (implementedInApiVersion, OBPAPI4_0_0.versionStatus)
private def getApiInfoJSON(apiVersion : ApiVersion, apiVersionStatus : String) = {
val organisation = APIUtil.getPropsValue("hosted_by.organisation", "TESOBE")
val email = APIUtil.getPropsValue("hosted_by.email", "contact@tesobe.com")
val phone = APIUtil.getPropsValue("hosted_by.phone", "+49 (0)30 8145 3994")
@ -2672,7 +2671,7 @@ trait APIMethods400 {
staticResourceDocs += ResourceDoc(
root,
root(OBPAPI4_0_0.version, OBPAPI4_0_0.versionStatus),
implementedInApiVersion,
"root",
"GET",
@ -2690,10 +2689,10 @@ trait APIMethods400 {
List(UnknownError, "no connector set"),
apiTagApi :: apiTagNewStyle :: Nil)
lazy val root : OBPEndpoint = {
def root (apiVersion : ApiVersion, apiVersionStatus: String): OBPEndpoint = {
case (Nil | "root" :: Nil) JsonGet _ => {
cc => Future {
getApiInfoJSON() -> HttpCode.`200`(cc.callContext)
getApiInfoJSON(apiVersion, apiVersionStatus) -> HttpCode.`200`(cc.callContext)
}
}
}

View File

@ -75,7 +75,7 @@ object OBPAPI4_0_0 extends OBPRestHelper with APIMethods130 with APIMethods140 w
private val endpoints: List[OBPEndpoint] = OBPAPI3_1_0.routes ++ endpointsOf4_0_0
// Filter the possible endpoints by the disabled / enabled Props settings and add them together
val routes : List[OBPEndpoint] = Implementations4_0_0.root :: // For now we make this mandatory
val routes : List[OBPEndpoint] = Implementations4_0_0.root(version, versionStatus) :: // For now we make this mandatory
getAllowedEndpoints(endpoints, allResourceDocs)
// register v4.0.0 apis first, Make them available for use!

View File

@ -81,7 +81,8 @@ object OBPAPI5_0_0 extends OBPRestHelper
private val endpoints: List[OBPEndpoint] = OBPAPI4_0_0.routes ++ endpointsOf5_0_0
// Filter the possible endpoints by the disabled / enabled Props settings and add them together
val routes : List[OBPEndpoint] = getAllowedEndpoints(endpoints, allResourceDocs)
val routes : List[OBPEndpoint] = Implementations4_0_0.root(version, versionStatus) :: // For now we make this mandatory
getAllowedEndpoints(endpoints, allResourceDocs)
// register v5.0.0 apis first, Make them available for use!
registerRoutes(routes, allResourceDocs, apiPrefix, true)

View File

@ -43,7 +43,7 @@ trait APIMethods510 {
staticResourceDocs += ResourceDoc(
root,
root(OBPAPI5_1_0.version, OBPAPI5_1_0.versionStatus),
implementedInApiVersion,
"root",
"GET",
@ -61,10 +61,10 @@ trait APIMethods510 {
List(UnknownError, "no connector set"),
apiTagApi :: apiTagNewStyle :: Nil)
lazy val root : OBPEndpoint = {
def root (apiVersion : ApiVersion, apiVersionStatus: String) : OBPEndpoint = {
case (Nil | "root" :: Nil) JsonGet _ => {
cc => Future {
JSONFactory510.getApiInfoJSON(implementedInApiVersion) -> HttpCode.`200`(cc.callContext)
JSONFactory510.getApiInfoJSON(apiVersion,apiVersionStatus) -> HttpCode.`200`(cc.callContext)
}
}
}

View File

@ -30,7 +30,7 @@ import code.api.Constant
import code.api.util.APIUtil
import code.api.util.APIUtil.gitCommit
import code.api.v4_0_0.{EnergySource400, HostedAt400, HostedBy400}
import com.openbankproject.commons.util.ScannedApiVersion
import com.openbankproject.commons.util.{ApiVersion, ScannedApiVersion}
case class APIInfoJsonV510(
@ -48,8 +48,7 @@ case class APIInfoJsonV510(
)
object JSONFactory510 {
def getApiInfoJSON(implementedInApiVersion: ScannedApiVersion) = {
val (apiVersion, apiVersionStatus) = (implementedInApiVersion, OBPAPI5_1_0.versionStatus)
def getApiInfoJSON(apiVersion : ApiVersion, apiVersionStatus: String) = {
val organisation = APIUtil.getPropsValue("hosted_by.organisation", "TESOBE")
val email = APIUtil.getPropsValue("hosted_by.email", "contact@tesobe.com")
val phone = APIUtil.getPropsValue("hosted_by.phone", "+49 (0)30 8145 3994")

View File

@ -65,7 +65,7 @@ object OBPAPI5_1_0 extends OBPRestHelper
val version : ApiVersion = ApiVersion.v5_1_0
val versionStatus = ApiVersionStatus.`BLEEDING-EDGE`.toString
val versionStatus = ApiVersionStatus.BLEEDING_EDGE.toString
// 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)
@ -81,7 +81,8 @@ object OBPAPI5_1_0 extends OBPRestHelper
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)
val routes : List[OBPEndpoint] = Implementations5_1_0.root(version, versionStatus) :: // For now we make this mandatory
getAllowedEndpoints(endpoints, allResourceDocs)
// register v5.1.0 apis first, Make them available for use!
registerRoutes(routes, allResourceDocs, apiPrefix, true)

View File

@ -31,7 +31,7 @@ object ApiShortVersions extends Enumeration {
object ApiVersionStatus extends Enumeration {
type Status = Value
val STABLE, `BLEEDING-EDGE`,DRAFT = Value
val STABLE, BLEEDING_EDGE,DRAFT = Value
}
sealed trait ApiVersion {