softwaremill / softwaremill/tapir

Relaxed enumeratum codecs

Open
#3,711 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.5k
Forks
468
Avg merge
5h 37m
Merged PRs (30d)
34

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TapirCodecEnumeratum entry points plainCodecEnumEntry and plainCodecEnumEntryDecodeCaseInsensitive. Reproduce an enumeratum value in a query parameter or path segment with different casing, then inspect how the codec is selected. Done means the intended default casing behavior is established and verified for those inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.