# EndpointInput.derived\[T\] inside helper method

**URL:** <https://softwaremill.community/t/endpointinput-derived-t-inside-helper-method/79>\
**Category:** tapir\
**Created:** [January 4, 2023, 10:30pm UTC](https://softwaremill.community/t/endpointinput-derived-t-inside-helper-method/79 "2023-01-04T22:30:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Xiong](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/jason_xiong/32/67_2.png) [@Jason\_Xiong](https://softwaremill.community/u/Jason_Xiong)\
**Post date:** [January 4, 2023, 10:30pm UTC](https://softwaremill.community/t/endpointinput-derived-t-inside-helper-method/79/1 "2023-01-04T22:30:07Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![adamw](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/adamw/32/28_2.png) [@adamw](https://softwaremill.community/u/adamw)\
**Post date:** [January 5, 2023, 7:51am UTC](https://softwaremill.community/t/endpointinput-derived-t-inside-helper-method/79/2 "2023-01-05T07:51:31Z")

</div>

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`.
