Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncApi schema - broken rendering of examples #3753

Closed
kamilkloch opened this issue May 8, 2024 · 0 comments · Fixed by #3757
Closed

AsyncApi schema - broken rendering of examples #3753

kamilkloch opened this issue May 8, 2024 · 0 comments · Fixed by #3757

Comments

@kamilkloch
Copy link
Contributor

/** 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant