Customize Schema Name of Generic Case Classes

Is it possible to customize the name of an auto-derived schema for a generic case class? Example:

case class Foo[T](t: T)

case class Bar()

endpoint.post.out(jsonBody[Foo[Bar]])

Generating OpenAPI docs on this endpoint will result in a schema with the name Foo_Bar, whereas I might want its name to actually be BarFoo or any other arbitrary name.

Thanks in advance for any help

You should be able to do something like:

jsonBody[Foo[Bar]].schema(_.name(SName("FooBar")))

Or suing an annotation:

@encodedName("FooBar")
case class Foo[T](t: T)

Though this sets is globally for all usages.

1 Like

Is there any way to set this as a different name for each instance?

Yes, using the first approach - you simply modify this at usage-site. Annotations are global.

1 Like