DEV Community

Aaron Gong
Aaron Gong

Posted on

Redoc With VueJS

Here is a very short post on using Redoc in VueJS.

Below is a component you can use in any VueJS project. Remember to install redoc and null dependencies.

<template>
  <h2>Redoc Sample</h2>
  <div id="redoc-container"></div>
</template>

<script setup>
// npm install redoc
// npm install null
import * as redoc from 'redoc/bundles/redoc.standalone' // requires null package
import { onMounted } from 'vue'

onMounted(() => {
  redoc.init('http://petstore.swagger.io/v2/swagger.json', { "expandResponses": "200,400" }, document.getElementById('redoc-container'))
})
</script>

<style scoped>
</style>
Enter fullscreen mode Exit fullscreen mode

That's all.

Top comments (0)