Repository: enzonotario/vitepress-openapi
Pull request #103 (2024-10-30 22:28:22)

Pages by tags
<!-- Provide a general summary of your changes in the title above. -->

# Description

Allows to generate pages by tags

## Related issues/external references
<!--
Format issues on GitHub as `#XXX`
-->

## Types of changes

- New feature


vercel[bot]: [vc]: #fRi1GYMVHWeG+PLjZaHQgeu1iljh/foWVwUW1Sl/qQo=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJ2aXRlcHJlc3Mtb3BlbmFwaSIsImxpdmVGZWVkYmFjayI6eyJyZXNvbHZlZCI6MCwidW5yZXNvbHZlZCI6MCwidG90YWwiOjAsImxpbmsiOiJ2aXRlcHJlc3Mtb3BlbmFwaS1naXQtZmVhdHVyZS10YWdzLWVuem8tbm90YXJpb3MtcHJvamVjdHMudmVyY2VsLmFwcCJ9LCJpbnNwZWN0b3JVcmwiOiJodHRwczovL3ZlcmNlbC5jb20vZW56by1ub3Rhcmlvcy1wcm9qZWN0cy92aXRlcHJlc3Mtb3BlbmFwaS9BOGJEWnliZGd3RjJyOVdrWWF0b3FRWE11Nk1mIiwicHJldmlld1VybCI6InZpdGVwcmVzcy1vcGVuYXBpLWdpdC1mZWF0dXJlLXRhZ3MtZW56by1ub3Rhcmlvcy1wcm9qZWN0cy52ZXJjZWwuYXBwIiwibmV4dENvbW1pdFN0YXR1cyI6IkRFUExPWUVEIn1dfQ==
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **vitepress-openapi** | ✅ Ready ([Inspect](https://vercel.com/enzo-notarios-projects/vitepress-openapi/A8bDZybdgwF2r9WkYatoqQXMu6Mf)) | [Visit Preview](https://vercel.live/open-feedback/vitepress-openapi-git-feature-tags-enzo-notarios-projects.vercel.app?via=pr-comment-visit-preview-link&passThrough=1) | 💬 [**Add feedback**](https://vercel.live/open-feedback/vitepress-openapi-git-feature-tags-enzo-notarios-projects.vercel.app?via=pr-comment-feedback-link) | Oct 30, 2024 10:28pm |


coderabbitai[bot]: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- This is an auto-generated comment: review in progress by coderabbit.ai -->

> [!NOTE]
> Currently processing new changes in this PR. This may take a few minutes, please wait...
> 
> <details>
> <summary>📥 Commits</summary>
> 
> Reviewing files that changed from the base of the PR and between 78e674b5498cdb28d1eafaf2f4aeb2a2d9bee569 and 1b511b23f4c7a9c9177750aa58ee25fe81999696.
> 
> </details>
> 
> <details>
> <summary>📒 Files selected for processing (14)</summary>
> 
> * `dev/.vitepress/config.ts` (1 hunks)
> * `dev/tags/[tag].md` (1 hunks)
> * `dev/tags/[tag].paths.js` (1 hunks)
> * `docs/.vitepress/config.mts` (1 hunks)
> * `docs/example/tags/[tag].md` (1 hunks)
> * `docs/example/tags/[tag].paths.js` (1 hunks)
> * `src/components/Common/OASpec.vue` (4 hunks)
> * `src/components/Path/OAPathsByTags.vue` (6 hunks)
> * `src/composables/usePaths.ts` (1 hunks)
> * `src/composables/useSidebar.ts` (2 hunks)
> * `src/lib/OpenApi.ts` (1 hunks)
> * `test/composables/usePaths.test.ts` (1 hunks)
> * `test/composables/useSidebar.test.ts` (5 hunks)
> * `test/testsConstants.ts` (2 hunks)
> 
> </details>
> 
> ```ascii
>  _____________________________
> < The Da Vinci Code Reviewer. >
>  -----------------------------
>   \
>    \   \
>         \ /\
>         ( )
>       .( o ).
> ```

<!-- end of auto-generated comment: review in progress by coderabbit.ai -->

<!-- usage_tips_start -->

> [!TIP]
> <details>
> <summary>CodeRabbit can enforce grammar and style rules using `languagetool`.</summary>
> 
> Configure `languagetool` in your project's settings in CodeRabbit enable/disable rules and categories. Refer to the [LanguageTool Community](https://community.languagetool.org/rule/list) to learn more.
> 
> </details>

<!-- usage_tips_end -->
<!-- tips_start -->

---

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
pkg-pr-new[bot]: 
[Open in Stackblitz](https://pkg.pr.new/template/63983f72-0adc-4a5c-8b82-698f3de05f1a)


```
pnpm add https://pkg.pr.new/vitepress-openapi@103
```


_commit: <a href="https://github.com/enzonotario/vitepress-openapi/runs/32308079720"><code>1b511b2</code></a>_


Patch:
diff --git a/dev/.vitepress/config.ts b/dev/.vitepress/config.ts
index 3383812..d849b49 100644
--- a/dev/.vitepress/config.ts
+++ b/dev/.vitepress/config.ts
@@ -16,21 +16,38 @@ export default defineConfigWithTheme({
     outline: [1, 3],
     sidebar: [
       {
-        text: 'Introduction',
-        link: '/',
-      },
-      ...sidebar.generateSidebarGroups(),
-      {
-        text: 'One Page',
-        link: '/one-page',
+        text: 'By Tags',
+        items: [
+          {
+            text: 'Introduction',
+            link: '/',
+          },
+          ...sidebar.itemsByTags(),
+        ],
       },
       {
-        text: 'Custom Slots',
-        link: '/custom-slots',
+        text: 'By Operations',
+        items: [
+          ...sidebar.generateSidebarGroups(),
+
+        ],
       },
       {
-        text: 'Multiple Specs',
-        link: '/multiple-specs',
+        text: 'Customizations',
+        items: [
+          {
+            text: 'One Page',
+            link: '/one-page',
+          },
+          {
+            text: 'Custom Slots',
+            link: '/custom-slots',
+          },
+          {
+            text: 'Multiple Specs',
+            link: '/multiple-specs',
+          },
+        ],
       },
       {
         text: 'Other',
diff --git a/dev/tags/[tag].md b/dev/tags/[tag].md
new file mode 100644
index 0000000..d8f6641
--- /dev/null
+++ b/dev/tags/[tag].md
@@ -0,0 +1,17 @@
+---
+aside: false
+outline: false
+title: vitepress-openapi
+---
+
+<script setup lang="ts">
+import { useRoute, useData } from 'vitepress'
+
+const route = useRoute()
+
+const { isDark } = useData()
+
+const tag = route.data.params.tag
+</script>
+
+<OASpec :tags="[tag]" :isDark="isDark" hide-info hide-servers hide-paths-summary />
diff --git a/dev/tags/[tag].paths.js b/dev/tags/[tag].paths.js
new file mode 100644
index 0000000..d19209f
--- /dev/null
+++ b/dev/tags/[tag].paths.js
@@ -0,0 +1,17 @@
+import { usePaths } from 'vitepress-openapi'
+import spec from '../../docs/public/openapi.json' assert { type: 'json' }
+
+export default {
+    paths() {
+        return usePaths({ spec })
+            .getTags()
+            .map(({ name }) => {
+                return {
+                    params: {
+                        tag: name,
+                        pageTitle: `${name} - vitepress-openapi`,
+                    },
+                }
+            })
+    },
+}
diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts
index 5a0143e..c59ded1 100644
--- a/docs/.vitepress/config.mts
+++ b/docs/.vitepress/config.mts
@@ -47,6 +47,10 @@ export default defineConfigWithTheme({
                 text: 'Info and Servers',
                 link: '/layouts/info-servers',
               },
+              {
+                text: 'Pages by Tags',
+                link: '/layouts/pages-by-tags',
+              },
             ],
           },
         ],
@@ -56,10 +60,6 @@ export default defineConfigWithTheme({
         items: [
           {
             items: [
-              // {
-              //   text: 'useOpenapi',
-              //   link: '/composables/useOpenapi',
-              // },
               {
                 text: 'useTheme',
                 link: '/composables/useTheme',
@@ -93,13 +93,23 @@ export default defineConfigWithTheme({
             text: 'Introduction',
             link: '/example/introduction',
           },
-          ...sidebar.generateSidebarGroups().map(group => ({
-            ...group,
-            items: group.items.map(item => ({
-              ...item,
-              link: `/example${item.link}`,
-            })),
-          })),
+          {
+            text: 'By Tags',
+            items: [
+              ...sidebar.itemsByTags({
+                linkPrefix: '/example/tags/',
+              }),
+            ],
+          },
+          {
+            text: 'By Operations',
+            items: [
+              ...sidebar.generateSidebarGroups({
+                linkPrefix: '/example/operations/',
+              }),
+            ],
+          },
+
           {
             text: 'Additional',
             items: [
diff --git a/docs/example/tags/[tag].md b/docs/example/tags/[tag].md
new file mode 100644
index 0000000..d8f6641
--- /dev/null
+++ b/docs/example/tags/[tag].md
@@ -0,0 +1,17 @@
+---
+aside: false
+outline: false
+title: vitepress-openapi
+---
+
+<script setup lang="ts">
+import { useRoute, useData } from 'vitepress'
+
+const route = useRoute()
+
+const { isDark } = useData()
+
+const tag = route.data.params.tag
+</script>
+
+<OASpec :tags="[tag]" :isDark="isDark" hide-info hide-servers hide-paths-summary />
diff --git a/docs/example/tags/[tag].paths.js b/docs/example/tags/[tag].paths.js
new file mode 100644
index 0000000..638d070
--- /dev/null
+++ b/docs/example/tags/[tag].paths.js
@@ -0,0 +1,17 @@
+import { usePaths } from 'vitepress-openapi'
+import spec from '../../public/openapi.json' assert { type: 'json' }
+
+export default {
+    paths() {
+        return usePaths({ spec })
+            .getTags()
+            .map(({ name }) => {
+                return {
+                    params: {
+                        tag: name,
+                        pageTitle: `${name} - vitepress-openapi`,
+                    },
+                }
+            })
+    },
+}
diff --git a/docs/layouts/pages-by-tags.md b/docs/layouts/pages-by-tags.md
new file mode 100644
index 0000000..9e66312
--- /dev/null
+++ b/docs/layouts/pages-by-tags.md
@@ -0,0 +1,63 @@
+---
+aside: false
+outline: false
+---
+
+# Pages by Tags
+
+You can use the `OASpec` component to render all operations that have a specific tag.
+
+## Creating Tags Pages
+
+To create tags pages, create a directory named `tags` in the `docs` directory. Inside the `tags` directory, create a file named `[tag].md` and a file named `[tag].paths.js`.
+
+```
+/docs
+├── /tags
+│   ├── [tag].md
+│   └── [tag].paths.js
+```
+
+Example of `[tag].paths.js`:
+
+```ts
+import { usePaths } from 'vitepress-openapi'
+import spec from '../public/openapi.json' assert { type: 'json' }
+
+export default {
+    paths() {
+        return usePaths({ spec })
+            .getTags()
+            .map(({ name }) => {
+                return {
+                    params: {
+                        tag: name,
+                        pageTitle: `${name} - vitepress-openapi`,
+                    },
+                }
+            })
+    },
+}
+```
+
+Example of `[tag].md`:
+
+```markdown
+---
+aside: false
+outline: false
+title: vitepress-openapi
+---
+
+<script setup lang="ts">
+import { useRoute, useData } from 'vitepress'
+
+const route = useRoute()
+
+const { isDark } = useData()
+
+const tag = route.data.params.tag
+</script>
+
+<OASpec :tags="[tag]" :isDark="isDark" hide-info hide-servers hide-paths-summary />
+```
diff --git a/docs/layouts/sidebar.md b/docs/layouts/sidebar.md
index 9b82804..63c7a19 100644
--- a/docs/layouts/sidebar.md
+++ b/docs/layouts/sidebar.md
@@ -29,3 +29,30 @@ module.exports = {
     },
 }
 ```
+
+## Items by tags
+
+To generate sidebar items by tags, you can use the `itemsByTags` function. Configure your `.vitepress/config.js` as follows:
+
+```ts
+import { useSidebar, useOpenapi } from 'vitepress-openapi'
+const spec = useOpenapi({ path: '../public/openapi.json' })
+
+const sidebar = useSidebar({ 
+    spec,
+    // Optionally, you can specify a link prefix for all generated sidebar items.
+    tagLinkPrefix: '/tags/',
+})
+
+module.exports = {
+    // ...
+    themeConfig: {
+        sidebar: [
+            ...sidebar.itemsByTags(),
+            
+            // Optionally, you can generate sidebar items with another link prefix.
+            ...sidebar.itemsByTags({ linkPrefix: '/v2/' }),
+        ],
+    },
+}
+```
diff --git a/src/components/Common/OASpec.vue b/src/components/Common/OASpec.vue
index 284ecc4..a05d398 100644
--- a/src/components/Common/OASpec.vue
+++ b/src/components/Common/OASpec.vue
@@ -27,6 +27,10 @@ const props = defineProps({
     type: Boolean,
     default: null,
   },
+  tags: {
+    type: Array,
+    default: undefined,
+  },
   hideDefaultFooter: {
     /**
      * @deprecated Use `hideBranding` instead
@@ -48,6 +52,10 @@ const props = defineProps({
       return false
     },
   },
+  hidePathsSummary: {
+    type: Boolean,
+    default: undefined,
+  },
 })
 
 const slots = defineSlots<OperationSlot>()
@@ -69,7 +77,7 @@ const showServers = !props.hideServers && servers.length
 
 const groupByTags = props.groupByTags ?? themeConfig.getSpecConfig().groupByTags
 
-const operationsTags = openapi.getOperationsTags()
+const operationsTags = props.tags ?? openapi.getOperationsTags()
 
 const paths = openapi.getPaths()
 </script>
@@ -89,6 +97,7 @@ const paths = openapi.getPaths()
       :openapi="openapi"
       :tags="operationsTags"
       :paths="paths"
+      :hide-paths-summary="props.hidePathsSummary === undefined ? undefined : props.hidePathsSummary"
     >
       <!-- Expose all slots upwards -->
       <template
diff --git a/src/components/Path/OAPathsByTags.vue b/src/components/Path/OAPathsByTags.vue
index e49d296..fae8910 100644
--- a/src/components/Path/OAPathsByTags.vue
+++ b/src/components/Path/OAPathsByTags.vue
@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { defineProps, nextTick, ref } from 'vue'
+import { computed, defineProps, nextTick, ref } from 'vue'
 import { Collapsible, CollapsibleTrigger } from 'vitepress-openapi/components/ui/collapsible'
 import { Button } from 'vitepress-openapi/components/ui/button'
 import { useI18n } from 'vue-i18n'
@@ -25,6 +25,10 @@ const props = defineProps({
     type: Boolean,
     default: false,
   },
+  hidePathsSummary: {
+    type: Boolean,
+    default: undefined,
+  },
 })
 
 const slots = defineSlots<OperationSlot>()
@@ -97,6 +101,11 @@ function onPathClick(tagPaths, hash) {
 }
 
 const lazyRendering = themeConfig.getSpecConfig().lazyRendering.value
+
+const showPathsSummary = computed(() => props.hidePathsSummary === undefined
+  ? themeConfig.getSpecConfig().showPathsSummary.value
+  : !props.hidePathsSummary,
+)
 </script>
 
 <template>
@@ -114,7 +123,7 @@ const lazyRendering = themeConfig.getSpecConfig().lazyRendering.value
       </OAHeading>
 
       <div
-        :class="{ 'md:grid-cols-2': themeConfig.getSpecConfig().showPathsSummary.value }"
+        :class="{ 'md:grid-cols-2': showPathsSummary }"
         class="grid grid-cols-1 gap-10"
       >
         <div>
@@ -124,7 +133,7 @@ const lazyRendering = themeConfig.getSpecConfig().lazyRendering.value
         </div>
 
         <div
-          v-if="themeConfig.getSpecConfig().showPathsSummary.value"
+          v-if="showPathsSummary"
           class="flex-1 my-[16px]"
         >
           <OAPathsSummary
@@ -136,7 +145,10 @@ const lazyRendering = themeConfig.getSpecConfig().lazyRendering.value
         </div>
       </div>
 
-      <div class="flex justify-center">
+      <div
+        v-if="showPathsSummary || themeConfig.getSpecConfig().collapsePaths.value === true"
+        class="flex justify-center"
+      >
         <CollapsibleTrigger>
           <Button>
             {{ tagPaths.isOpen ? $t('Hide operations') : $t('Show operations') }}
diff --git a/src/composables/usePaths.ts b/src/composables/usePaths.ts
index d8826c6..cb46d80 100644
--- a/src/composables/usePaths.ts
+++ b/src/composables/usePaths.ts
@@ -1,11 +1,33 @@
 import { OpenApi } from 'vitepress-openapi'
+import { transformSpec } from '../lib/transformSpec'
+import type { OpenAPI } from './useOpenapi'
 
 export function usePaths({
   spec,
+}: {
+  spec: OpenAPI
 }) {
-  const openapi = OpenApi({ spec })
+  const openapi = OpenApi({ spec, transformedSpec: transformSpec(spec) })
+
+  function getTags() {
+    const operationsTags = openapi.getOperationsTags()
+
+    const tags = openapi.getTags()
+      .filter(({ name }) => operationsTags.includes(name))
+
+    return tags
+      .concat([
+        ...operationsTags
+          .filter(tag => !tags.map(({ name }) => name).includes(tag))
+          .map(tag => ({
+            name: tag,
+            description: null,
+          })),
+      ])
+  }
 
   return {
     getPathsByVerbs: openapi.getPathsByVerbs,
+    getTags,
   }
 }
diff --git a/src/composables/useSidebar.ts b/src/composables/useSidebar.ts
index af9082f..e414495 100644
--- a/src/composables/useSidebar.ts
+++ b/src/composables/useSidebar.ts
@@ -1,4 +1,5 @@
 import { OpenApi, httpVerbs, useOpenapi } from 'vitepress-openapi'
+import type { OpenAPI } from './useOpenapi'
 
 interface GenerateSidebarGroupsOptions {
   tags?: string[] | null
@@ -15,17 +16,24 @@ interface GenerateSidebarGroupOptions {
 const defaultOptions = {
   spec: null,
   linkPrefix: '/operations/',
+  tagLinkPrefix: '/tags/',
 }
 
 export function useSidebar({
   spec,
   linkPrefix,
+  tagLinkPrefix,
+}: {
+  spec?: OpenAPI
+  linkPrefix?: string
+  tagLinkPrefix?: string
 } = {
   ...defaultOptions,
 }) {
   const options = {
     spec: spec || useOpenapi().json,
     linkPrefix: linkPrefix || defaultOptions.linkPrefix,
+    tagLinkPrefix: tagLinkPrefix || defaultOptions.tagLinkPrefix,
   }
 
   const openapi = OpenApi({ spec: options.spec })
@@ -124,10 +132,29 @@ export function useSidebar({
     return groups
   }
 
+  function itemsByTags({
+    tags,
+    linkPrefix,
+  }: GenerateSidebarGroupsOptions = {}) {
+    tags = tags || openapi.getOperationsTags()
+    linkPrefix = linkPrefix || options.tagLinkPrefix
+
+    if (!openapi.getPaths()) {
+      return []
+    }
+
+    return tags.map(tag => ({
+      text: tag,
+      link: `${linkPrefix}${tag}`,
+    }))
+  }
+
   return {
     sidebarItemTemplate,
     generateSidebarItem,
     generateSidebarGroup,
     generateSidebarGroups,
+    itemsByTags,
+    // TODO: Add `itemsByOperations` function
   }
 }
diff --git a/src/lib/OpenApi.ts b/src/lib/OpenApi.ts
index da64592..69addea 100644
--- a/src/lib/OpenApi.ts
+++ b/src/lib/OpenApi.ts
@@ -239,7 +239,11 @@ export function OpenApi({
   }
 
   function getTags() {
-    return spec?.tags ?? []
+    return (spec?.tags ?? [])
+      .map(({ name, description }) => ({
+        name: name ?? null,
+        description: description ?? null,
+      }))
   }
 
   return {


Test patch:
diff --git a/test/composables/openapi.test.ts b/test/composables/openapi.test.ts
index 1a48bab..ed755ab 100644
--- a/test/composables/openapi.test.ts
+++ b/test/composables/openapi.test.ts
@@ -27,7 +27,7 @@ describe('openapi with spec', () => {
 
   it('returns the correct tags for getTags', () => {
     const result = openapi.getOperationsTags()
-    expect(result).toEqual(['users'])
+    expect(result).toEqual(['users', 'pets'])
   })
 
   it('returns the correct security schemes for getSecuritySchemes', () => {
@@ -180,10 +180,16 @@ describe('openapi with spec', () => {
   it('getTags returns tags object', () => {
     const api = createOpenApiInstance({ spec })
     const tags = api.getTags()
-    expect(tags).toEqual([{
-      name: 'users',
-      description: 'Operations about users',
-    }])
+    expect(tags).toEqual([
+      {
+        name: 'users',
+        description: 'Operations about users',
+      },
+      {
+        name: 'pets',
+        description: 'Operations about pets',
+      },
+    ])
   })
 
   it('getTags returns empty array if no tags in spec', () => {
diff --git a/test/composables/usePaths.test.ts b/test/composables/usePaths.test.ts
new file mode 100644
index 0000000..1b89b07
--- /dev/null
+++ b/test/composables/usePaths.test.ts
@@ -0,0 +1,78 @@
+import { describe, expect, it } from 'vitest'
+import { usePaths } from '../../src'
+import { spec } from '../testsConstants'
+
+describe('usePaths', () => {
+  const paths = usePaths({ spec })
+
+  it('returns the correct paths by verbs', () => {
+    const result = paths.getPathsByVerbs()
+    expect(result).toEqual([
+      {
+        path: '/users',
+        verb: 'get',
+        operationId: 'getUsers',
+        summary: 'GET /users',
+        tags: ['users'],
+      },
+      {
+        path: '/users/{id}',
+        verb: 'get',
+        operationId: 'getUser',
+        summary: 'GET /users/{id}',
+        tags: ['users'],
+      },
+      {
+        path: '/users/{id}/pets',
+        verb: 'get',
+        operationId: 'getUserPets',
+        summary: 'Get a list of pets for a user',
+        tags: ['pets'],
+      },
+    ])
+  })
+
+  it('returns the correct tags', () => {
+    const result = paths.getTags()
+    expect(result).toEqual([
+      { name: 'users', description: 'Operations about users' },
+      { name: 'pets', description: 'Operations about pets' },
+    ])
+  })
+
+  it('returns operationsTags and Tags', () => {
+    const result = usePaths({
+      spec: {
+        openapi: '3.0.0',
+        paths: {
+          '/users': {
+            get: {
+              tags: ['users'],
+            },
+          },
+          '/users/{id}': {
+            get: {
+              tags: ['missingTag'],
+            },
+          },
+          '/users/{id}/pets': {
+            get: {
+              tags: ['pets'],
+            },
+          },
+        },
+        tags: [
+          { name: 'users', description: 'Users operations' },
+          { name: 'pets' },
+          { name: 'tagWithoutOperations' },
+        ],
+      },
+    }).getTags()
+
+    expect(result).toEqual([
+      { name: 'users', description: 'Users operations' },
+      { name: 'pets', description: null },
+      { name: 'missingTag', description: null },
+    ])
+  })
+})
diff --git a/test/composables/useSidebar.test.ts b/test/composables/useSidebar.test.ts
index 4399967..8f15738 100644
--- a/test/composables/useSidebar.test.ts
+++ b/test/composables/useSidebar.test.ts
@@ -26,12 +26,17 @@ describe('useSidebar', () => {
             link: '/operations/getUser',
             text: sidebar.sidebarItemTemplate('get', 'GET /users/{id}'),
           },
+        ],
+        text: 'users',
+      },
+      {
+        items: [
           {
             link: '/operations/getUserPets',
-            text: sidebar.sidebarItemTemplate('get', 'GET /users/{id}/pets'),
+            text: sidebar.sidebarItemTemplate('get', 'Get a list of pets for a user'),
           },
         ],
-        text: 'users',
+        text: 'pets',
       },
     ])
   })
@@ -54,7 +59,7 @@ describe('useSidebar', () => {
         },
         {
           link: '/ref/getUserPets',
-          text: sidebar.sidebarItemTemplate('get', 'GET /users/{id}/pets'),
+          text: sidebar.sidebarItemTemplate('get', 'Get a list of pets for a user'),
         },
       ],
       text: 'users',
@@ -78,12 +83,17 @@ describe('useSidebar with linkPrefix', () => {
             link: '/foo/getUser',
             text: sidebar.sidebarItemTemplate('get', 'GET /users/{id}'),
           },
+        ],
+        text: 'users',
+      },
+      {
+        items: [
           {
             link: '/foo/getUserPets',
-            text: sidebar.sidebarItemTemplate('get', 'GET /users/{id}/pets'),
+            text: sidebar.sidebarItemTemplate('get', 'Get a list of pets for a user'),
           },
         ],
-        text: 'users',
+        text: 'pets',
       },
     ])
   })
@@ -101,12 +111,17 @@ describe('useSidebar with linkPrefix', () => {
             link: '/foo/getUser',
             text: sidebar.sidebarItemTemplate('get', 'GET /users/{id}'),
           },
+        ],
+        text: 'users',
+      },
+      {
+        items: [
           {
             link: '/foo/getUserPets',
-            text: sidebar.sidebarItemTemplate('get', 'GET /users/{id}/pets'),
+            text: sidebar.sidebarItemTemplate('get', 'Get a list of pets for a user'),
           },
         ],
-        text: 'users',
+        text: 'pets',
       },
     ])
 
@@ -122,13 +137,52 @@ describe('useSidebar with linkPrefix', () => {
             link: '/bar/getUser',
             text: sidebar.sidebarItemTemplate('get', 'GET /users/{id}'),
           },
+        ],
+        text: 'users',
+      },
+      {
+        items: [
           {
             link: '/bar/getUserPets',
-            text: sidebar.sidebarItemTemplate('get', 'GET /users/{id}/pets'),
+            text: sidebar.sidebarItemTemplate('get', 'Get a list of pets for a user'),
           },
         ],
-        text: 'users',
+        text: 'pets',
       },
     ])
   })
 })
+
+describe('itemsByTags', () => {
+  const sidebar = useSidebar({ spec })
+
+  it('returns the correct items for given tags', () => {
+    const result = sidebar.itemsByTags({ tags: ['users', 'pets'] })
+    expect(result).toEqual([
+      { text: 'users', link: '/tags/users' },
+      { text: 'pets', link: '/tags/pets' },
+    ])
+  })
+
+  it('returns the correct items with a custom linkPrefix', () => {
+    const result = sidebar.itemsByTags({ tags: ['users', 'pets'], linkPrefix: '/custom/' })
+    expect(result).toEqual([
+      { text: 'users', link: '/custom/users' },
+      { text: 'pets', link: '/custom/pets' },
+    ])
+  })
+
+  it('returns the correct items when no tags are provided', () => {
+    const result = sidebar.itemsByTags()
+    expect(result).toEqual([
+      { text: 'users', link: '/tags/users' },
+      { text: 'pets', link: '/tags/pets' },
+    ])
+  })
+
+  it('returns an empty array when there are no paths', () => {
+    const emptySidebar = useSidebar({ spec: {} })
+    const result = emptySidebar.itemsByTags()
+    expect(result).toEqual([])
+  })
+})
diff --git a/test/testsConstants.ts b/test/testsConstants.ts
index ca80d48..5f21030 100644
--- a/test/testsConstants.ts
+++ b/test/testsConstants.ts
@@ -78,8 +78,9 @@ export const spec = {
           },
         ],
         tags: [
-          'users',
+          'pets',
         ],
+        summary: 'Get a list of pets for a user',
       },
     },
   },
@@ -119,6 +120,10 @@ export const spec = {
       name: 'users',
       description: 'Operations about users',
     },
+    {
+      name: 'pets',
+      description: 'Operations about pets',
+    },
   ],
 }