Gathering detailed insights and metrics for egg-swagger-decorator-plus
Gathering detailed insights and metrics for egg-swagger-decorator-plus
Gathering detailed insights and metrics for egg-swagger-decorator-plus
Gathering detailed insights and metrics for egg-swagger-decorator-plus
npm install egg-swagger-decorator-plus
Typescript
Module System
Min. Node Version
Node Version
NPM Version
71.3
Supply Chain
98.4
Quality
75
Maintenance
100
Vulnerability
99.6
License
TypeScript (100%)
Total Downloads
415
Last Day
1
Last Week
1
Last Month
2
Last Year
48
351 Stars
28 Commits
80 Forks
9 Watching
4 Branches
3 Contributors
Latest Version
0.1.2
Package Id
egg-swagger-decorator-plus@0.1.2
Unpacked Size
49.21 kB
Size
14.06 kB
File Count
24
NPM Version
6.10.2
Node Version
12.8.0
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
1
Compared to previous week
Last month
0%
2
Compared to previous month
Last year
-48.9%
48
Compared to previous year
using decorator to auto generate swagger json docs
1npm install egg-swagger-decorator
using decorator to auto generate swagger json docs
based on Swagger OpenAPI Specification 2.0
// using commonds below to start and test the example server
git clone https://github.com/Cody2333/egg-swagger-decorator.git
cd egg-swagger-decorator
npm install
npm run dev
finally open:
http://localhost:7001/swagger-html
// router.js
import { Application } from 'egg';
import { wrapper } from '../lib';
export default (app: Application) => {
wrapper(app, {
// // [optional] default is /swagger-html
// swaggerHtmlEndpoint: '/sw',
// // [optional] default is /swagger-json
// swaggerJsonEndpoint: '/sj',
// // [optional] default is false. if true, will call makeSwaggerRouter(app) automatically
// makeswaggerRouter: false,
title: 'foo',
version: 'v1.0.0',
description: 'bar',
});
makeSwaggerRouter(app);
};
// controller/test.ts
import { Controller } from 'egg';
import { request, summary, query, path, body, tags } from 'egg-swagger-decorator';
const testTag = tags(['test']);
const userSchema = {
name: { type: 'string', required: true },
gender: { type: 'string', required: false, example: 'male' },
groups: {
type: 'array',
required: true,
items: { type: 'string', example: 'group1' }
}
};
export default class Test extends Controller{
@request('get', '/users')
@summary('get user list')
@testTag
@query({
type: { type: 'number', required: true, default: 1, description: 'type' }
})
public async getUsers() {
const { ctx } = this;
const users = [{user1: {name: 'xxx'}}]
ctx.body = { users };
}
@request('get', '/users/{id}')
@summary('get user info by id')
@testTag
@path({
id: { type: 'number', required: true, default: 1, description: 'id' }
})
public async getUser() {
const { id } = this.ctx.params;
const user = {user1: {id, name: 'xxx'}}
this.ctx.body = { user };
}
@request('post', '/users')
@testTag
@body(userSchema)
public async postUser() {
const body = this.ctx.request.body;
this.ctx.body = { result: body };
}
public async temp(ctx) {
ctx.body = { result: 'success' };
}
}
request // @request('POST', '/users')
tags // @tags(['example'])
query // @query({limit: {type: 'number', required: true, default: 10, description: 'desc'}})
path // @path({limit: {type: 'number', required: true, default: 10, description: 'desc'}})
body // @body({groups: {type: 'array', required: true, items: { type: 'string', example: 'group1' }}})
formData // @formData({file: {type: 'file', required: true, description: 'file content'}})
middlewares
// support koa middlewares.
// eg. @middlewares([func1,func2])
summary // @summary('api summary')
description // @description('api description')
responses
// @responses({ 200: { description: 'success'}, 400: { description: 'error'}})
// responses is optional
© MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
Found 2/26 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
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
license file not detected
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-12-23
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