Package Exports
- tswagger
- tswagger/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tswagger) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
TSwagger
TS-Swagger plugin generator CLI
Installation
npm i -D tswaggerBasic Usage
in project directory
npx tswagger https://api.server.foo/swagger.jsonin script code
import { setAxios, api } from './api'
import axios from 'axios'
setInstance(axios.create({ baseURL: 'http://localhost:8080', timeout: 100 })) // optional
const foo = await api.bar.get()Path param mode
see form option
/* default (1.1.0+) */
api.foo.bar(1).get(2)
api.foo.bar.get()
/* underscore */
api.foo._bar.get(1, 2)
api.foo.bar.get()Options
options priority : command line > tswagger.config > package.json
tswagger argument1 --option1 value1 --option2 value2| option | description | default | example |
|---|---|---|---|
| (first argument) | Swagger schema JSON path | (required) | http://.. or ./foo/swagger.json |
src |
same as first argument | first argument | same as above |
plugins-dir |
Directory | '' |
|
plugin-name |
Name for generated flile | api |
|
export-name |
Export name | {plugin-name} |
''(export default) |
type-path |
Path for scheme type file | {plugins-dir}/{plugin-name}/{types.ts} |
./types/models.ts |
base-path |
base path | /v1 |
/v2 |
skip-header |
Ignore parameter in header | false |
true |
form |
Path param interface mode | (undefined) | underscore |
Set options using tswagger.config
import { Options } from 'tswagger'
const option: Partial<Options> = {
pluginName: 'foo'
}
export default optionSet options using package.json
{
"scripts": {
"swagger": "tswagger"
},
"tswagger": {
"pluginName": "foo",
"src": "https://api.server.foo/swagger.json"
}
}tsconfig.json
{
"compilerOptions": {
"types": ["tswagger/types"]
}
}and npm run swagger or npx tswagger
License
ISC License Copyright (c) 2023, Elevista