airframe icon indicating copy to clipboard operation
airframe copied to clipboard

airframe-rpc: Support setting default method parameter for the generated RPC clients

Open xerial opened this issue 4 years ago • 2 comments

@RPC
trait MyAPI {
  // Default argument
  def hello(message:String = "world"): String
}

If we have this RPC interface, currently the generated client doesn't populate the default parameter ("hello").

xerial avatar Jun 19 '21 17:06 xerial

A workaround is wrapping method arguments with an object:

@RPC
trait MyAPI {
  def hello(request:HelloRequest): String
}

case class HelloRequest(message: String = "world")

xerial avatar Aug 14 '21 01:08 xerial

As setting default parameter requires copying Scala code from API to client side code, it's not recommended in general. We should document that limitation #2169

xerial avatar Jan 09 '24 02:01 xerial