forked from jiangwenyang/swagger-to-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jiangwenyang
committed
Aug 3, 2021
0 parents
commit f5d712c
Showing
31 changed files
with
3,187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
"@typescript-eslint/naming-convention": "warn", | ||
"@typescript-eslint/semi": "warn", | ||
"curly": "warn", | ||
"eqeqeq": "warn", | ||
"no-throw-literal": "warn", | ||
"semi": "off" | ||
}, | ||
"ignorePatterns": [ | ||
"out", | ||
"dist", | ||
"**/*.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
.env.production | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// A launch configuration that compiles the extension and then opens it inside a new window | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run Extension", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}" | ||
], | ||
"outFiles": [ | ||
"${workspaceFolder}/out/**/*.js" | ||
], | ||
"preLaunchTask": "${defaultBuildTask}" | ||
}, | ||
{ | ||
"name": "Extension Tests", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}", | ||
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index" | ||
], | ||
"outFiles": [ | ||
"${workspaceFolder}/out/test/**/*.js" | ||
], | ||
"preLaunchTask": "${defaultBuildTask}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"files.exclude": { | ||
"out": false // set this to true to hide the "out" folder with the compiled JS files | ||
}, | ||
"search.exclude": { | ||
"out": true // set this to false to include "out" folder in search results | ||
}, | ||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts | ||
"typescript.tsc.autoDetect": "off" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "watch", | ||
"problemMatcher": "$tsc-watch", | ||
"isBackground": true, | ||
"presentation": { | ||
"reveal": "never" | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.vscode/** | ||
.vscode-test/** | ||
out/test/** | ||
|
||
src/** | ||
.gitignore | ||
.yarnrc | ||
vsc-extension-quickstart.md | ||
**/tsconfig.json | ||
**/.eslintrc.json | ||
**/*.map | ||
**/*.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--ignore-engines true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### 0.0.1 (2021-08-03) | ||
* Initial Release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Swagger To API | ||
自动获取Swagger文档并根据模板生成API | ||
|
||
模板参考 [Hygen](https://www.hygen.io/) | ||
|
||
## 特性 | ||
|
||
* 支持Workspace | ||
* 自动生成Hygen模板 | ||
* 根据分类对API进行分组选择 | ||
* 批量生成API | ||
|
||
## 使用 | ||
|
||
### 配置 | ||
|
||
插件支持vscode配置或者使用项目配置文件,项目配置文件优先级更高。 | ||
|
||
支持以下配置方式: | ||
|
||
- 项目根目录下的package.json中定义swagger字段 | ||
- 项目根目录下的 swaggerrc.[json|yaml|yml|js|cjs]文件 | ||
- 项目根目录下的 swagger.[config.js|config.cjs]文件 | ||
|
||
#### 示例 | ||
|
||
`.swaggerrc.json` | ||
|
||
```json | ||
{ | ||
"services": [ | ||
{ | ||
"name": "user", | ||
"url": "http://36.110.47.222:28172/user/v2/api-docs" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
#### 字段 | ||
|
||
##### `services` | ||
|
||
配置服务 | ||
|
||
- `services[n].name` Swagger名称 | ||
- `service[n].url` Swagger地址 | ||
|
||
### 命令 | ||
|
||
提供`swagger-to-api.init` 和 `swagger-to-api.gen` 两个命令分别用于生成模板和生成API。使用快捷键 `Ctrl+Shift+P` (Mac对应 `Command+Shift+p`) 打开命令输入框输入对应命令 | ||
|
||
- `swagger-to-api.init` | ||
|
||
如果当前项目还没有`_tepmlates` 目录模板,则使用此命令生成默认的模板文件。 | ||
|
||
|
||
|
||
- `swagger-to-api.gen` | ||
|
||
选择对应的API并生成API到对应的文件(需要保证文件存在) | ||
|
||
|
||
## TODO | ||
|
||
- [ ] 自动生成API文件引用 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"name": "swagger-to-api", | ||
"displayName": "Swagger To API", | ||
"publisher": "jiangwenyang", | ||
"icon": "images/logo.png", | ||
"description": "从swagger快速生成API文件", | ||
"version": "0.0.1", | ||
"engines": { | ||
"vscode": "^1.58.0" | ||
}, | ||
"categories": [ | ||
"Other" | ||
], | ||
"keywords": [ | ||
"swagger", | ||
"api", | ||
"gen" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/jiangwenyang/swagger-to-api/issues", | ||
"email": "[email protected]" | ||
}, | ||
"homepage": "https://github.com/jiangwenyang/swagger-to-api/blob/main/README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jiangwenyang/swagger-to-api" | ||
}, | ||
"activationEvents": [ | ||
"onCommand:swagger-to-api.init", | ||
"onCommand:swagger-to-api.gen" | ||
], | ||
"main": "./out/extension/index.js", | ||
"contributes": { | ||
"commands": [ | ||
{ | ||
"command": "swagger-to-api.init", | ||
"title": "init", | ||
"category": "swagger-to-api" | ||
}, | ||
{ | ||
"command": "swagger-to-api.gen", | ||
"title": "gen", | ||
"category": "swagger-to-api" | ||
} | ||
], | ||
"configuration": [ | ||
{ | ||
"title": "swagger-to-api", | ||
"properties": { | ||
"swagger-to-api.services": { | ||
"type": "array", | ||
"default": [] | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "yarn run compile", | ||
"compile": "tsc -p ./", | ||
"watch": "tsc -watch -p ./", | ||
"pretest": "yarn run compile && yarn run lint", | ||
"lint": "eslint src --ext ts", | ||
"test": "node ./out/test/runTest.js" | ||
}, | ||
"devDependencies": { | ||
"@types/cosmiconfig": "^6.0.0", | ||
"@types/glob": "^7.1.3", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "14.x", | ||
"@types/node-fetch": "^2.5.12", | ||
"@types/vscode": "^1.58.0", | ||
"@typescript-eslint/eslint-plugin": "^4.26.0", | ||
"@typescript-eslint/parser": "^4.26.0", | ||
"eslint": "^7.27.0", | ||
"glob": "^7.1.7", | ||
"mocha": "^8.4.0", | ||
"typescript": "^4.3.2", | ||
"vscode-test": "^1.5.2" | ||
}, | ||
"dependencies": { | ||
"@types/fs-extra": "^9.0.12", | ||
"cosmiconfig": "^7.0.0", | ||
"fs-extra": "^10.0.0", | ||
"hygen": "^6.1.0", | ||
"lodash": "^4.17.21", | ||
"node-fetch": "^2.6.1" | ||
} | ||
} |
Oops, something went wrong.