Gathering detailed insights and metrics for @liuguanghui/swagger-vue
Gathering detailed insights and metrics for @liuguanghui/swagger-vue
npm install @liuguanghui/swagger-vue
Typescript
Module System
Node Version
NPM Version
66.1
Supply Chain
97.6
Quality
75.1
Maintenance
100
Vulnerability
98.9
License
JavaScript (81.37%)
Handlebars (18.63%)
Total Downloads
4,304
Last Day
2
Last Week
3
Last Month
33
Last Year
178
2 Stars
12 Commits
2 Forks
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
2.0.3
Package Id
@liuguanghui/swagger-vue@2.0.3
Unpacked Size
49.52 kB
Size
12.34 kB
File Count
22
NPM Version
6.11.3
Node Version
12.12.0
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
-66.7%
3
Compared to previous week
Last month
3,200%
33
Compared to previous month
Last year
-48%
178
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.getApi(opt) 12fs.writeFileSync(path.join(__dirname, '../config/api.js'), codeResult)//生成API文档 13 14const filterContent = swaggerGen.getFilter(opt) 15fs.writeFileSync(path.join(__dirname, '../config/filter.js'), filterContent)//生成filter文档及枚举
1const swaggerGen = require('swagger-vue') 2const fs = require('fs') 3const path = require('path') 4const url = 'http://demo.api.com'; 5 6swaggerGen.apiRequest(url).then(jsondata=>{ 7 let opt = { 8 swagger: jsonData, 9 moduleName: 'api', 10 className: 'api' 11 } 12 13 // const codeResult = swaggerGen.getApi(opt, [‘xxx’,'xxx']) //1.0.2支持传入生成需要的function,xxx-operationID 14 const codeResult = swaggerGen.getApi(opt) 15 fs.writeFileSync(path.join(__dirname, '../config/api.js'), codeResult)//生成API文档 16 17 const filterContent = swaggerGen.getFilter(opt) 18 fs.writeFileSync(path.join(__dirname, '../config/filter.js'), filterContent)//生成filter文档及枚举 19})
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 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
30 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
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