title: "Introduction"
description: "The nuxt-swaggerjsonapi module for Nuxt"
position: 1
category: ""
menuTitle: "Introduction"
features:
- Automatically add API to application
- Quickly copy API method and data to page, component, layout, vuex and Middleware
- Friendly @nuxtjs/axios integration
- Provide address generation swagger.json And Provide local swagger.json File path
Setup
Add nuxt-swaggerjsonapi dependency to your project
npm install nuxt-swaggerjsonapi
or
yarn add nuxt-swaggerjsonapi
Recommended use @nuxtjs/axios
yarn add @nuxtjs/axios
Then add it to the modules section in your nuxt.config.js
export default {
modules: ["@nuxtjs/axios", "nuxt-swaggerjsonapi"],
plugins: ["~plugins/api"],
};
Configure
const path = require("path");
export default {
modules: ["@nuxtjs/axios", "nuxt-swaggerjsonapi"],
plugins: ["~plugins/api"],
swaggerJsonApi: {
SourcePath: path.resolve(__dirname, "swagger.json"),
OutputPath: path.resolve(__dirname, "./plugins/api/api.js"),
Model: "details",
},
};
- Sourcepath: Swagger.json route
- OutputPath: Api.js route
Development environment api.js And formal environment api.js The difference between
Model: "" (default)
Model: "details"
Author
LICENSE
MIT