smithy4s icon indicating copy to clipboard operation
smithy4s copied to clipboard

Open enums: add `fromStringOrUnknown` convenience method

Open kubukoz opened this issue 1 year ago • 1 comments

Currently, we only have def fromString and a def $unknown. I think it'd be useful to have a total, Option-less function like def fromStringOrUnknown(s: String): TheEnum generated in all open enums' companion objects.

kubukoz avatar Dec 11 '24 15:12 kubukoz

Agreed

Baccata avatar Jan 02 '25 09:01 Baccata

I was thinking to make it something that these enums inherit from a supertype, but we currently don't have a trait OpenEnumeration or anything like that. Let's just generate this verbatim for the time being.

kubukoz avatar May 16 '25 20:05 kubukoz

https://github.com/disneystreaming/smithy4s/blob/1f0d08e20d0f0d97ef4d1ff404f94bf0b8da1e65/modules/codegen/src/smithy4s/codegen/internals/Renderer.scala#L1313-L1317

kubukoz avatar Jun 20 '25 15:06 kubukoz

Hey, I would like to work for its solution

Jay-Lokhande avatar Jun 20 '25 16:06 Jay-Lokhande