
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@braken/http-swagger
Advanced tools
Braken 框架的 HTTP Swagger 插件,提供 OpenAPI/Swagger 文档生成支持。
pnpm add @braken/http-swagger
import { Controller } from '@braken/http';
import Swagger from '@braken/http-swagger';
import { t } from '@braken/json-schema';
// 创建 Swagger 实例
const swagger = new Swagger({
users: '用户管理',
orders: '订单管理'
});
// 定义响应类型
const UserSchema = t.Object({
id: t.Number(),
name: t.String(),
email: t.String()
});
// 定义控制器
@swagger.Controller('用户管理', '用户相关的 API 接口', 'users')
@swagger.ContentType('application/json')
@swagger.ResponseType('application/json')
class UserController extends Controller {
@swagger.Parameter('id', 'path', t.Number())
@swagger.Response(200, UserSchema)
async getUser(ctx) {
// ...
}
@swagger.Parameter('user', 'body', UserSchema)
@swagger.Response(201, UserSchema)
async createUser(ctx) {
// ...
}
}
// 生成文档
const docs = swagger.toJSON();
主要的 Swagger 文档生成类,提供以下功能:
定义 API 参数:
@swagger.Parameter(name: string, inwhere: SwaggerParameterInWhere, value: JSONSchemaObject)
定义请求内容类型:
@swagger.ContentType(...types: string[])
定义响应内容类型:
@swagger.ResponseType(...types: string[])
定义响应结构:
@swagger.Response(code: number, value: JSONSchemaObject)
定义控制器文档:
@swagger.Controller(summary: string, description: string, ...tags: string[])
type SwaggerParameterInWhere =
| "query" // URL 查询参数
| "header" // 请求头参数
| "path" // 路径参数
| "cookie" // Cookie 参数
| "formData" // 表单数据
| "body"; // 请求体
// 自动加载定义文件
await swagger.autoLoadDefinitons('./definitions');
MIT
FAQs
somethings
We found that @braken/http-swagger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.