# How to setup schema in Raw Web Socket?

**URL:** <https://softwaremill.community/t/how-to-setup-schema-in-raw-web-socket/146>\
**Category:** tapir\
**Created:** [March 3, 2023, 12:36pm UTC](https://softwaremill.community/t/how-to-setup-schema-in-raw-web-socket/146 "2023-03-03T12:36:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonid](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@leonid](https://softwaremill.community/u/leonid)\
**Post date:** [March 3, 2023, 12:36pm UTC](https://softwaremill.community/t/how-to-setup-schema-in-raw-web-socket/146/1 "2023-03-03T12:36:30Z")

</div>

Hello! could you please give a simple example how do i set up the schema? Ultimately, I need it to generate AsyncApi.

[https://tapir.softwaremill.com/en/latest/endpoint/websockets.html#raw-web-sockets](https://tapir.softwaremill.com/en/latest/endpoint/websockets.html#raw-web-sockets)

typed web sockets is not suitable for me as it closes the connection on request decoding errors

---

<div class="post-metadata">

**Author:** ![adamw](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/adamw/32/28_2.png) [@adamw](https://softwaremill.community/u/adamw)\
**Post date:** [March 6, 2023, 10:03am UTC](https://softwaremill.community/t/how-to-setup-schema-in-raw-web-socket/146/2 "2023-03-06T10:03:49Z")

</div>

What you’ll need to do in this case is use the `.requestSchema` / `.responseSchema` methods on the web socket output. The schema can be derived, though you’ll need to transform it so that it’s a schema for `WebSocketFrame`: this disables run-time validations, but the documentations should be ok. For example:

```plaintext
  case class MyFrame(data: String)
  val myWsOutput = webSocketBodyRaw(AkkaStreams)
    .requestsSchema(Schema.derived[MyFrame].as[WebSocketFrame])
  endpoint.out(myWsOutput)

```

---

<div class="post-metadata">

**Author:** ![leonid](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@leonid](https://softwaremill.community/u/leonid)\
**Post date:** [March 6, 2023, 10:23am UTC](https://softwaremill.community/t/how-to-setup-schema-in-raw-web-socket/146/3 "2023-03-06T10:23:55Z")

</div>

thanks, now it works as expected
