softwaremill / tapir

Rapid development of self-documenting APIs
https://tapir.softwaremill.com
Apache License 2.0
1.34k stars 404 forks source link

Relaxed enumeratum codecs #3711

Open Fristi opened 3 months ago

Fristi commented 3 months ago

Tapir version: 1.10.5

Scala version: 2.12.12

Describe the bug

The TapirCodecEnumeratum contains two methods

def plainCodecEnumEntryDecodeCaseInsensitive[E <: EnumEntry](implicit `enum`: Enum[E]): Codec.PlainCodec[E] = plainCodecEnumEntryUsing(
    `enum`.withNameInsensitiveOption
  )

  implicit def plainCodecEnumEntry[E <: EnumEntry](implicit `enum`: Enum[E]): Codec.PlainCodec[E] = plainCodecEnumEntryUsing(
    `enum`.withNameOption
  )

While plainCodecEnumEntry is defined as implicit, I would rather prefer have plainCodecEnumEntryDecodeCaseInsensitive to be the default? Such that for query parameters, path segments and such the case sensitivity is ignored

How to reproduce?

Define a enumeratum enum and use it an query param of path segment while changing the expected casing, it will break fairly easy

Additional information

Fristi commented 3 months ago

Is this still relevant, otherwise we could close this?

adamw commented 3 months ago

I don't now :) What's the behavior of other enum codecs? What are the defaults usually? That would need spending some time on to research properly.