Gathering detailed insights and metrics for swagger-vue
Gathering detailed insights and metrics for swagger-vue
Gathering detailed insights and metrics for swagger-vue
Gathering detailed insights and metrics for swagger-vue
npm install swagger-vue
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
173 Stars
27 Commits
62 Forks
4 Watching
1 Branches
7 Contributors
Updated on 27 Nov 2024
JavaScript (65.35%)
HTML (34.65%)
Cumulative downloads
Total Downloads
Last day
-70.5%
49
Compared to previous day
Last week
57.2%
662
Compared to previous week
Last month
122.2%
3,029
Compared to previous month
Last year
-57.5%
15,953
Compared to previous year
3
Swagger to JS & Vue & Axios Codegen
1npm install swagger-vue --dev
1const swaggerGen = require('swagger-vue') 2const jsonData = require('../api-docs.json') 3const fs = require('fs') 4const path = require('path') 5 6let opt = { 7 swagger: jsonData, 8 moduleName: 'api', 9 className: 'api' 10} 11const codeResult = swaggerGen(opt) 12fs.writeFileSync(path.join(__dirname, '../dist/api.js'), codeResult)
Create Gruntfile.js
1const fs = require('fs') 2const path = require('path') 3const swaggerGen = require('swagger-vue') 4 5module.exports = function(grunt) { 6 7 grunt.initConfig({ 8 'pkg': grunt.file.readJSON('package.json'), 9 'swagger-vue-codegen': { 10 options: { 11 swagger: "<%= pkg.swagger.definition %>", 12 className: "<%= pkg.swagger.className %>", 13 moduleName: "vue-<%= pkg.swagger.moduleName %>", 14 dest: 'client/javascript' 15 }, 16 dist: { 17 18 } 19 } 20 }); 21 22 grunt.registerMultiTask('swagger-vue-codegen', function() { 23 var callback = this.async(); 24 var opt = this.options(); 25 var distFileName = path.join(opt.dest, opt.moduleName + '.js'); 26 27 fs.readFile(opt.swagger, function(err, data) { 28 if (err) { 29 grunt.log.error(err.toString()); 30 callback(false); 31 } else { 32 var parsedData = JSON.parse(data); 33 34 var codeResult = swaggerGen({ 35 swagger: parsedData, 36 moduleName: opt.moduleName, 37 className: opt.className 38 }); 39 40 fs.writeFile(distFileName, codeResult, function(err) { 41 if (err) { 42 grunt.log.error(err.toString()); 43 callback(false); 44 } else { 45 grunt.log.writeln('Generated ' + distFileName + ' from ' + opt.swagger); 46 } 47 }) 48 } 49 }); 50 }); 51 52 grunt.registerTask('vue', ['swagger-vue-codegen']); 53 54}; 55
And set options in package.json
1... 2 "swagger": { 3 "definition": "client/swagger.json", 4 "className": "API", 5 "moduleName": "api-client" 6 } 7...
Now you can use grunt vue
to run build task
In Vue.js main file set API domain
1import { setDomain } from './lib/api-client.js' 2setDomain('http://localhost:3000/api')
Import API function into Vue.js component, for example to log in
1import { user_login as userLogin } from '../lib/api-client.js' 2 3userLogin({ 4 credentials: { 5 username: 'admin', 6 password: 'admin' 7 } 8}).then(function (response) { 9 console.log(response.data) // {id: "<token>", ttl: 1209600, created: "2017-01-01T00:00:00.000Z", userId: 1} 10})
All requests use axios module with promise, for more information about that follow axios documentation
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 5/19 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More