# Supporting Tag Groups

**URL:** https://softwaremill.community/t/supporting-tag-groups/235
**Category:** tapir
**Created:** [June 26, 2023, 1:03pm UTC](https://softwaremill.community/t/supporting-tag-groups/235 "2023-06-26T13:03:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gerryfletch](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/gerryfletch/32/102_2.png) [@gerryfletch](https://softwaremill.community/u/gerryfletch)
#### Post date: [June 26, 2023, 1:03pm UTC](https://softwaremill.community/t/supporting-tag-groups/235/1 "2023-06-26T13:03:37Z")

</div>

Hello,

Redoc supports the `x-tagGroup` extension, which gives an additional layer of nesting in the endpoints column on the left hand-side of the generated website. See the pet store example:

> **[ReDoc Interactive Demo](https://redocly.github.io/redoc/)**
>
> ReDoc Interactive Demo. OpenAPI/Swagger-generated API Reference Documentation

> <https://github.com/Redocly/redoc/blob/main/demo/openapi-3-1.yaml#L78-L90>

I’m aware that I can extend the generated documentation with some primitive types, e.g keys with lists of strings etc. but how would I go about creating the tag group object?

I would have thought a case class with a Circe encoder/decoder would suffice but unfortunately not.

Any help would be greatly appreciated 🙏

---

<div class="post-metadata">

### Author: ![kciesielski](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/kciesielski/32/133_2.png) [@kciesielski](https://softwaremill.community/u/kciesielski)
#### Post date: [June 28, 2023, 8:06am UTC](https://softwaremill.community/t/supporting-tag-groups/235/2 "2023-06-28T08:06:48Z")

</div>

@gerryfletch I have just tried to add this extension in a pet project, and it works as expected.

1. Define a case class for tag groups

```auto
  case class TagGroupDocExtension(name: String, tags: List[String])

```

1. Build a list of groups:

```auto
  val tagGroupsExtension =
    DocsExtension.of(
      "x-tagGroups",
      List(
        TagGroupDocExtension(
          "General",
          List("pet", "store")
        ),
        TagGroupDocExtension("User Management", List("user"))
      )
    )

```

1. Annotate your endpoints with tags

```auto
  val exampleEndpoint: sttp.tapir.Endpoint[Unit, Example, String, String, Any] = endpoint.get
    .in("test" / path[Example]("testId"))
    .out(stringBody)
    .errorOut(stringBody)
    .tag("store")

```

Make sure all tags listed in `tagGroupsExtension` are used in your endpoints.

1. Define documentation endpoints, referring to `tagGroupsExtension`

```auto
  val docEndpoints: List[ServerEndpoint[Any, IO]] = RedocInterpreter()
    .fromServerEndpoints[IO](apiEndpoints, Info("title", "version"), List(tagGroupsExtension))

```

Note: If you additionally use `OpenAPIDocsInterpreter` to create a yaml file, please note that the extensions will be specified in the end of the specs file.

1. Bind your endpoints and start the server, the groups should be visible in the redoc UI.

---

<div class="post-metadata">

### Author: ![gerryfletch](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/gerryfletch/32/102_2.png) [@gerryfletch](https://softwaremill.community/u/gerryfletch)
#### Post date: [June 28, 2023, 9:01am UTC](https://softwaremill.community/t/supporting-tag-groups/235/3 "2023-06-28T09:01:37Z")

</div>

@kciesielski do you mind sharing your imports for that snippet?

That’s precisely what I tried before, but couldn’t get the JsonCodec stuff to work:

```auto
Cannot find a codec between types: String and List[TagGroupDocExtension], formatted as: sttp.tapir.CodecFormat.Json

```

---

<div class="post-metadata">

### Author: ![kciesielski](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/kciesielski/32/133_2.png) [@kciesielski](https://softwaremill.community/u/kciesielski)
#### Post date: [June 28, 2023, 9:59am UTC](https://softwaremill.community/t/supporting-tag-groups/235/4 "2023-06-28T09:59:28Z")

</div>

Sure, here are the imports I used to get circe generic autoderivation, Tapir schema generic autoderivation, and Tapir\<\>circe interop

```auto
import io.circe.generic.auto.*
import sttp.tapir.generic.auto.*
import sttp.tapir.json.circe.*

```

---

<div class="post-metadata">

### Author: ![gerryfletch](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/gerryfletch/32/102_2.png) [@gerryfletch](https://softwaremill.community/u/gerryfletch)
#### Post date: [June 28, 2023, 2:14pm UTC](https://softwaremill.community/t/supporting-tag-groups/235/5 "2023-06-28T14:14:22Z")

</div>

I must have been missing an import there - working a charm now, thanks ever so much @kciesielski !
