
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
swagger-codegen-next
Advanced tools
generate .ts api files by swagger.json
npm install swagger-codegen-next -g
yarn global add swagger-codegen-next
swagger-codegen.config.js
// swagger-codegen.config.js
const path = require("path");
const cwd = process.cwd();
module.exports = {
// swagger文件地址
url: "http://***/swagger.json",
// 输出目录
output: {
path: path.join(cwd, "services"), // default
},
// 获取接口模块名称
getModuleName(url) {
return /api\/([^\/]*)/.exec(url)[1];
},
// 获取接口名
getMethodName(operationId) {
return operationId;
},
// 需要跳过生成的接口
exclude: [],
template: {
http: 'import http from "../http";'
}
};
Now you can run the swagger-codegen-next:
swagger-codegen-next
support HTTP/HTTPS
{
"url": "http://***.swaggger.json" // https://***.swagger.json
}
support absolute path
{
"url": path.resolve(__dirname, "./swagger.json")
}
The output property tells swagger-codegen-next where to emit the api files .
{
output: {
path: path.join(cwd, 'services') // default
},
}
The getModuleName method can help swagger-codegen-next to group the APIs.
{
getModuleName(url){
return /api\/([^\/]*)/.exec(url)[1]
}
}
add getMethodName to support to customize the name of a method.
skip target swagger paths
eg:
exclude: ["/api/user/add"]
MIT
FAQs
根据swagger.json生成api文件
We found that swagger-codegen-next demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.