Skip to content

Commit 6643746

Browse files
authored
Merge pull request #187 from enzonotario/feature/update-vitepress-openapi
Update vitepress-openapi && Bruno code samples
2 parents 0529d0f + 273e398 commit 6643746

File tree

5 files changed

+44
-44
lines changed

5 files changed

+44
-44
lines changed

bun.lockb

-56 Bytes
Binary file not shown.

docs/.vitepress/theme/components/TabBlock.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const props = defineProps<{
3939
// Generate service tabs from compose configuration
4040
const serviceTabs = computed(() => {
4141
if (!props.compose?.services) return []
42-
42+
4343
return Object.entries(props.compose.services).map(([serviceName, config]) => ({
4444
title: `${serviceName} Configuration`,
4545
content: {
@@ -81,8 +81,8 @@ const setActiveTab = (index: number) => {
8181
8282
type Direction = 'next' | 'prev'
8383
const navigateTab = (direction: Direction) => {
84-
const newIndex = direction === 'next'
85-
? (currentIndex.value + 1) % allTabs.value.length
84+
const newIndex = direction === 'next'
85+
? (currentIndex.value + 1) % allTabs.value.length
8686
: (currentIndex.value - 1 + allTabs.value.length) % allTabs.value.length
8787
setActiveTab(newIndex)
8888
}
@@ -97,7 +97,7 @@ const isLastTab = computed(() => currentIndex.value === allTabs.value.length - 1
9797
<template>
9898
<div class="tabs-container">
9999
<div class="tabs-navigation">
100-
<button
100+
<button
101101
class="group nav-arrow"
102102
@click="navigateTab('prev')"
103103
aria-label="Previous tab"
@@ -117,7 +117,7 @@ const isLastTab = computed(() => currentIndex.value === allTabs.value.length - 1
117117
</button>
118118
</div>
119119

120-
<button
120+
<button
121121
class="group nav-arrow"
122122
@click="navigateTab('next')"
123123
aria-label="Next tab"
@@ -138,12 +138,12 @@ const isLastTab = computed(() => currentIndex.value === allTabs.value.length - 1
138138
<h3 class="text-lg font-medium">{{ tab.content.service.name }}</h3>
139139
<code class="text-sm block mt-2">Image: {{ tab.content.service.image }}</code>
140140
</div>
141-
141+
142142
<div class="env-vars">
143143
<h4 class="font-medium mb-3">Environment Variables</h4>
144144
<ul class="env-list space-y-2">
145-
<li v-for="env in tab.content.service.envVars"
146-
:key="env.name"
145+
<li v-for="env in tab.content.service.envVars"
146+
:key="env.name"
147147
class="env-var flex items-start gap-2">
148148
<code class="text-sm px-2 py-1 bg-[var(--vp-c-bg-soft)] rounded shrink-0 text-[var(--vp-c-text-2)]">{{ env.name }}</code>
149149
<span v-if="env.value" class="text-sm text-[var(--vp-c-text-2)]">
@@ -161,12 +161,12 @@ const isLastTab = computed(() => currentIndex.value === allTabs.value.length - 1
161161
<h4 v-if="tab.content.subtitle" class="font-medium text-lg">{{ tab.content.subtitle }}</h4>
162162

163163
<ul v-if="tab.content.items" class="space-y-2">
164-
<li v-for="(item, itemIndex) in tab.content.items"
164+
<li v-for="(item, itemIndex) in tab.content.items"
165165
:key="itemIndex"
166166
class="flex items-center gap-2">
167167
<template v-if="item.icon && item.label">
168168
<span class="text-lg">{{ item.icon }}</span>
169-
<span class="font-mono font-medium">{{ item.label }}:</span>
169+
<span class="font-mono font-medium">{{ item.label }}:</span>
170170
<span>{{ item.value }}</span>
171171
</template>
172172
<template v-else-if="item.code">
@@ -192,7 +192,7 @@ const isLastTab = computed(() => currentIndex.value === allTabs.value.length - 1
192192
</div>
193193
</div>
194194
</template>
195-
<style>
195+
<style scoped>
196196
.tabs-container {
197197
@apply my-6;
198198
}

docs/.vitepress/theme/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import type { Theme } from "vitepress";
44

55
// Import OpenAPI components
6-
import { theme, useOpenapi } from "vitepress-openapi";
6+
import { theme, useOpenapi } from "vitepress-openapi/client";
77

88
// Import default theme
99
import DefaultTheme from "vitepress/theme";

docs/api-reference/api/operations/[operation].md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,56 @@ toc: false
77

88
<script setup lang="ts">
99
import { useData } from 'vitepress'
10-
import { useTheme, generateCodeSample } from 'vitepress-openapi'
10+
import { useTheme, generateCodeSample } from 'vitepress-openapi/client'
1111

12-
const { params, isDark } = useData()
12+
const { params } = useData()
1313
const operation = params.value.operation
1414

1515
const themeConfig = {
1616
codeSamples: {
1717
langs: [
18-
// 'bruno',
18+
'bruno',
1919
...useTheme().getCodeSamplesLangs(),
2020
],
2121
availableLanguages: [
22-
// {
23-
// lang: 'bruno',
24-
// label: 'Bruno',
25-
// highlighter: 'plaintext',
26-
// },
22+
{
23+
lang: 'bruno',
24+
label: 'Bruno',
25+
highlighter: 'plaintext',
26+
},
2727
...useTheme().getCodeSamplesAvailableLanguages(),
2828
],
29-
defaultLang: 'curl',
30-
generator: (lang, request) => {
31-
// if (lang === 'bruno') {
32-
// return generateBrunoRequest(request) || ''
33-
// }
29+
defaultLang: 'bruno',
30+
generator: async (lang, request) => {
31+
if (lang === 'bruno') {
32+
return generateBrunoRequest(request) || ''
33+
}
3434
return generateCodeSample(lang, request) || ''
3535
},
3636
}
3737
}
3838

39-
// function generateBrunoRequest(request) {
40-
// if (!request) return ''
41-
// const { method, url, headers, body } = request
42-
// let brunoScript = `${method} ${url}\n`
39+
function generateBrunoRequest(request) {
40+
if (!request) return ''
41+
const { method, url, headers, body } = request
42+
let brunoScript = `${method} ${url}\n`
4343

44-
// if (headers && Object.keys(headers).length) {
45-
// brunoScript += '\nHeaders\n'
46-
// for (const [key, value] of Object.entries(headers)) {
47-
// brunoScript += `${key}: ${value}\n`
48-
// }
49-
// }
44+
if (headers && Object.keys(headers).length) {
45+
brunoScript += '\nHeaders\n'
46+
for (const [key, value] of Object.entries(headers)) {
47+
brunoScript += `${key}: ${value}\n`
48+
}
49+
}
5050

51-
// if (body) {
52-
// brunoScript += '\nBody\n'
53-
// brunoScript += typeof body === 'string' ? body : JSON.stringify(body, null, 2)
54-
// }
51+
if (body) {
52+
brunoScript += '\nBody\n'
53+
brunoScript += typeof body === 'string' ? body : JSON.stringify(body, null, 2)
54+
}
5555

56-
// return brunoScript
57-
// }
56+
return brunoScript
57+
}
5858

5959
useTheme(themeConfig)
6060
</script>
6161

62-
<OAOperation :operationId="operation" :isDark="isDark" />
62+
<OAOperation :operationId="operation" />

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
"dependencies": {
3535
"@vueuse/core": "12.5.0",
3636
"globe.gl": "2.39.7",
37-
"vitepress-openapi": "0.0.3-alpha.55"
37+
"vitepress-openapi": "0.0.3-alpha.62"
3838
}
39-
}
39+
}

0 commit comments

Comments
 (0)