Skip to content

Commit

Permalink
Set maxVersion for staticExposedGetMethods to C5_2
Browse files Browse the repository at this point in the history
  • Loading branch information
BenYip123 committed Jul 2, 2024
1 parent 464de76 commit 64b031c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 612 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import net.corda.rest.tools.annotations.extensions.path
import net.corda.rest.tools.annotations.extensions.title
import net.corda.rest.tools.annotations.validation.RestInterfaceValidator
import net.corda.rest.tools.isStaticallyExposedGet
import net.corda.rest.tools.maxVersion
import net.corda.rest.tools.methodDescription
import net.corda.rest.tools.responseDescription
import net.corda.utilities.debug
Expand Down Expand Up @@ -169,7 +170,7 @@ internal class APIStructureRetriever(private val opsImplList: List<PluggableRest
method.kotlinFunction?.returnType?.isMarkedNullable ?: false
),
method.getInvocationMethod(clazz),
retrieveApiVersionsSet(annotation.minVersion, annotation.maxVersion)
retrieveApiVersionsSet(annotation.minVersion, method.maxVersion)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package net.corda.rest.tools

import net.corda.rest.annotations.RestApiVersion
import net.corda.rest.ws.DuplexChannel
import java.lang.reflect.Method

private data class MethodDocs(val methodDescription: String, val responseDescription: String)
private data class MethodDocs(val methodDescription: String, val responseDescription: String, val maxVersion: RestApiVersion)

/**
* These methods are automatically exposed from the HTTP-RPC functionality as GET methods.
Expand All @@ -15,7 +16,8 @@ private val staticExposedGetMethods: Map<String, MethodDocs> =
mapOf(
"getProtocolVersion" to MethodDocs(
"Returns the version of the endpoint",
"An integer value specifying the version of the endpoint"
"An integer value specifying the version of the endpoint",
RestApiVersion.C5_2
)
)
.mapKeys { it.key.lowercase() }
Expand All @@ -34,4 +36,9 @@ val Method.responseDescription: String
return staticExposedGetMethods[name.lowercase()]?.responseDescription ?: ""
}

val Method.maxVersion: RestApiVersion
get() {
return staticExposedGetMethods[name.lowercase()]!!.maxVersion
}

fun Class<*>.isDuplexChannel(): Boolean = (this == DuplexChannel::class.java)
Loading

0 comments on commit 64b031c

Please sign in to comment.