enum protobuff autoconverter for async api generates objects, while I want a string type with possible values
for swagger i have next implicit and with work good
implicit def pbEnumTypeCodec[T <: GeneratedEnum](
implicit c: GeneratedEnumCompanion[T]): Codec[String, T, CodecFormat.TextPlain] = {
def decode(name: String): DecodeResult[T] = c.fromName(name) match {
case Some(v) => DecodeResult.Value(v)
case None => DecodeResult.Error(name, throw InvalidArgument("type does not exist"))
}
def encode(id: T): String = id.name
Codec.string.mapDecode(decode)(encode).validate(Validator.enumeration(c.values.toList))
}
for async api i try write next impliciе
implicit def pbEnumTypeSchema[T <: GeneratedEnum](implicit c: GeneratedEnumCompanion[T]): Schema[T] =
Schema(
SchemaType.SString(),
validator = Validator.enumeration(c.values.toList),
)
the type was changed from ref to string, but I did not get an enumeration of possible values.
I have thoughts on how to add a tag, perhaps tell me how to do it correctly?
I expect to get something like this:
MyProtobufEnum:
required:
- value
type: object
properties:
value:
type: string
enum:
- VALUE1
- VALUE2