EndpointInput.derived[T] inside helper method

I’m trying to put some of the common boilerplate we use when defining endpoints into a helper function, but am having trouble genericizing the EndpointInput.derived[T] call.
For example I have the following code:

def tapirEndpointHelper[I]() = {
    endpoint.in(EndpointInput.derived[I])
  }

@endpointInput("asdf")
case class EndpointInputClass(
  // some fields
)

tapirEndpointHelper[EndpointInputClass]

This fails to compile with the exception Request endpoint can only be generated for a case class, but got: I.
Is there something I can add to the type bounds or something to force tapir to recognize that I’m passing in a case class here?

The EndpointInput.derived method is a macro, so it must be able to access at compile-time the exact class, for which code should be generated. In your case, the macro just sees a type parameter I (as the method can be called with an arbitrary type parameter), hence no compile-time generation is possible.

So you’ll need to parametrise your helper with the generated EndpointInput, and use tapirEndpointHelper[EIC](EndpointInput.derived). Alternatively, you can turn your tapirEndpoitnHelper into a macro, thus ensuring that it will be expanded at call-site with access to the appropriate info. This is in fact quite trivial if you are on Scala 3, and could be as simple as making the helper method inline.