Protobuf Enum to AsyncApi

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

for those who will solve a similar problem:

  implicit def pbEnumTypeSchema[T <: GeneratedEnum](implicit c: GeneratedEnumCompanion[T]): Schema[T] =
    Schema(
      SchemaType.SString(),
      validator = Validator.enumeration(c.values.toList, v => Some(v.name), Some(SName("enum"))),
    )

Sorry I somehow missed the topic, maybe adding Datatypes integrations — tapir 1.x documentation would work as well?

no, TapirCodecEnumeratum didn’t work for my case.
Now using implicit for ptotobuf GeneratedEnum I get completely correct behavior.

For json i have next decoder/encoder:

  implicit def pbEnumTypeEncoder[T <: GeneratedEnum]: Encoder[T] = Encoder.encodeString.contramap(_.name)

  implicit def pbEnumTypeDecoder[T <: GeneratedEnum](implicit c: GeneratedEnumCompanion[T]): Decoder[T] = {
    Decoder.decodeString.map(c.fromName(_).getOrElse(throw InvalidArgument("type does not exist")))
  }