The OpenApiDocs Nuxt Module is designed to seamlessly integrate OpenAPI documentation into Nuxt.js applications, supporting both Nuxt 2.x and 3.x. It utilizes Vue.js components to render the OpenAPI specifications dynamically. This module is ideal for developers looking to embed API documentation directly into their Nuxt.js projects.
work with static and server target
Version | Supported Nuxt Version |
---|---|
4.x | 2.x and 3.x |
5.0,5.1 | 3.x |
>=5.2 | >=3.7 |
npx nuxi@latest module add nuxt-openapi-docs-module
For Nuxt 3:
export default defineNuxtConfig({
modules: [
'nuxt-openapi-docs-module'
]
})
For Nuxt 2:
module.exports = {
modules: [
'nuxt-openapi-docs-module',
],
}
Customize the module by modifying the 'nuxt.config.js' or 'nuxt.config.ts' file:
const logo = readFileSync(`./assets/svg/logo.svg`);
module.exports = {
modules: [
[
'nuxt-openapi-docs-module',
{
folder: './docs/openapi', // Path to the folder containing OpenAPI specification files
name: 'OpenApiDocs', // Name of the main component
files: function() { // Function returning an object mapping file names to display names
return {
'news-api': 'News API',
'pages-api': 'Pages API docs'
}
},
debug: true, // Enable debug mode to print information to the console
list: true, // Toggle the display of document listings
locales: ['en', 'fr', 'es'], // Define supported locales
logo: logo.toString(), // Path to a custom logo in SVG format
footer: '© 2024 Company Name. All rights reserved.' // Custom footer content
}
]
],
// Additional configurations...
}
Option | Description |
---|---|
folder | Path to the folder containing OpenAPI specification files. |
name | Name of the main component. |
files | Function returning an object mapping file names to display names. |
debug | Enable debug mode to print information to the console. |
list | Toggle the display of document listings. |
locales | Define supported locales. |
logo | Custom logo in SVG format. |
footer | Custom footer content. |
Place your OpenAPI specification files (e.g., 'api1.yaml'', 'api2.yaml') in the specified 'folder'.