grunt-swagger-vue
Swagger Codegen for Vue.js
fork of swagger-vue
Getting Started
Requirements
Installation
npm install grunt-swagger-vue --save-dev
Configuration
grunt;
Load task
grunt;
Example
Add in your package.json
... "swagger": ...
Create Gruntfile.js
module { grunt; grunt; grunt; };
Execute in terminal
grunt vue
Generated client's usage
In Vue.js main file initialize the API plugin with domain param.
Vue
Import API models into Vue.js component, for example import user model and use login method to generate a new token.
user
Then set the Authorization header for all future request.
var token = responsedataAccessToken // now access token is set
You can also clear it for logout purpose
AccessTokenclear // Authorization header is now empty
All requests use axinos module returning a promise, for more information about that follow axios documentation
Notes
Code generator is only compatible with Swagger v2 and generated client is exported in ES6