🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

🔧 Programmierung 🕛 kürzlich 4 Min Lesezeit
0

Create elegant OpenAPI spec documentation with Rapi Doc and Vitepress

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

I recently had to create a documentation page supporting OpenAPI spec documentation. What's an OpenAPI spec documentation? A page, either self-hosted or included in your API management platform, that allows users to check what endpoints, methods, webhooks, etc., are available based on OpenAPI JSON or YAML.



I needed to find a balance between needing as many customization options as possible and using ready-to-go tools for quick setup and deployment.



And I found



With the component ready, I needed a tool to write documentation that supported custom components.



So I chose



And my browser froze.



Woohoo, long live the infinite loop!



What happened? So, since rapi-doc is a web component, I need to explicitly tell Vue compiler to not parse it. To just leave it alone.



And inside my config.mts file I needed to add:




CODE
import { defineConfig } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({
...
vue: {
template: {
compilerOptions: {
isCustomElement: (tag: string) => {
return tag.indexOf('rapi-doc') >= 0;
}
}
}
},
})







We just need to check for custom elements and inform Vue "hey, this tag is off-limits".



So, we have it, it runs!





This error means that during build-time, Vite couldn't access a self property. This can also happen if you try to access browser API (e.g., window) from server (in Nuxt or any other SSR framework, for example).



So what we can do? We can import it dynamically in runtime!



Let's change our import from this:




CODE
<script setup>
import 'rapidoc';
</script>






To this:




CODE
<script setup>
import { onMounted } from 'vue';

onMounted(() => {
import('rapidoc');
});
</script>






And now build should pass with no issues! Enjoy you API spec docs!






Bonus: Dark Mode



Vitepress comes with dark mode, working out-of-the-box. But how can we make our RapiDoc documentation reacting to mode changes?



We can use Vitepress core composable - useData. It contains isDark property with information if the darkmode is enabled or not.



So let's use it inside the script section in the SFC:




CODE
<script setup>
import { useData } from 'vitepress';
import { ref } from 'vue';

const data = useData();
const theme = ref(data.isDark.value ? 'dark' : 'light')
</script>






Now when we have a theme ref, we can pass it to the rapi-doc Web Component via attribute binding:




CODE
<template>
<div>
<rapi-doc
spec-url = "https://petstore.swagger.io/v2/swagger.json"
render-style = "read"
:theme="theme"
style = "height:100vh; width:100%"
> </rapi-doc>
</div>
</template>






We need to add one more thing for dark mode to work correctly - responding to theme change.



Let's add a watcher to our script section:




CODE
watch(data.isDark, (isDark) => {
theme.value = isDark ? 'dark' : 'light';
})






And voila, you created API docs that react to theme changes!



Image description

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Hackers Just Poisoned the Rust Supply Chain | Threat Wire
1 Quelle
Hackers Found a Way Into Humanoid Robots | Threat Wire
1 Quelle
Bits und so #1021 (Passwort für Laufwerk)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Create elegant OpenAPI spec documentation with Rapi Doc and Vitepress

Thematisch verwandte Begriffe: Create, elegant, OpenAPI, spec · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...