https://github.com/nefe/swag-engine
auto generate awesome API code using swagger
https://github.com/nefe/swag-engine
Last synced: 3 months ago
JSON representation
auto generate awesome API code using swagger
- Host: GitHub
- URL: https://github.com/nefe/swag-engine
- Owner: nefe
- Created: 2018-02-18T11:21:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-23T06:05:13.000Z (about 7 years ago)
- Last Synced: 2024-10-04T08:48:35.530Z (9 months ago)
- Language: TypeScript
- Size: 56.6 KB
- Stars: 4
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
Awesome Lists containing this project
README
# swag-engine
swagger2ts transfer Swagger docs to a controller, which help you write your owner API code and definetion
## usage
### use in code
```typescript
import { Cmd } from 'swag-engine';const cmd = new Cmd(rootPath?, customConfig?);
(async function() {
// sync remote docs data
await cmd.ready();// get docs update information
const { boDiffs, modDiffs } = cmd.diff();// boDiffs.details: string[] modDiffs.details: string[]
// update docs information
cmd.updateMod(mod);
cmd.updateBo(bo);
cmd.updateAll();// write API code with docs information
cmd.write();// data persistence to swag.lock like yarn.lock
cmd.save();// reget new docs information
await cmd.syncNew();
}())
```### use as cmd
#### config
* originUrl(string)
swagger api url
* outDir(string)
auto generate code file path
* templatePath(string)
your custom template path
* prettierConfig(object)
generated code is formatted by prettier, your can config your prettier style here;
* lockPath(string)
lock file path, swag-engine lock the current code version use a lockFile