tapir
tapir copied to clipboard
AsyncApi schema - broken rendering of examples
/** Broken rendering of examples.
*
* Result:
* ```
* messages:
* Apple:
* examples:
* - payload:
* - color: red
* - color: green
* ```
*
* Expected:
* ```
* messages:
* Apple:
* examples:
* - payload:
* color: red
* - payload:
* color: green
* ```
*/
object AsyncApiExample3 {
case class Apple(color: String)
private implicit val circeConfig: Configuration = Configuration.default
implicit val fruitCodec: io.circe.Codec[Apple] = deriveConfiguredCodec
val ws = endpoint.get
.in("ws")
.out(
webSocketBody[Apple, CodecFormat.Json, Apple, CodecFormat.Json](Fs2Streams[IO])
.responsesExample(Apple("red"))
.responsesExample(Apple("green"))
)
val asyncApiYaml = AsyncAPIInterpreter()
.toAsyncAPI(ws, "web socket", "1.0")
.toYaml
def main(args: Array[String]): Unit = println(asyncApiYaml)
}
Repo with sources: https://github.com/kamilkloch/tapir-async-api/blob/master/src/main/scala/AsyncApiExample3.scala