3.0.0 • Published 6 months ago
nuxtswagger v3.0.0
NuxTSwagger
Nuxt-TS-Swagger plugin generator CLI
Installation
npm i -D nuxtswagger
Requirements
Nuxt
base project
Basic Usage
in Nuxt project directory
npx nuxtswagger https://api.server.foo/swagger.json
in script code
import { api } from '~/lib/api'
await api().foo.post()
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 > nuxt.config
> package.json
nuxtswagger 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 | Nuxt plugins directory | plugins | |
plugin-name | Name for generated plugin | api | |
inject | Nuxt plugin inject key | {plugin-name} | |
type-path | Path for scheme type file | {plugins-dir}/{plugin-name}/{types.ts} | ./types/swagger.d.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 package.json
{
"nuxtswagger": {
"pluginName": "foo",
"src": "https://api.server.foo/swagger.json"
}
}
Set options using nuxt.config
v1.2+
export default defineNuxtConfig({
nuxtswagger: [
{ pluginName: 'foo', src: 'https://api.server.foo/swagger.json' },
{ pluginName: 'bar', src: 'https://api.server.bar/swagger.json' },
],
runtimeConfig: {
public: {
nuxtswagger: {
pluginName: 'foo',
// AxiosRequestConfig?
axiosConfig: { baseURL: 'https://api-stage.server.foo' }
},
},
},
})
tsconfig.json
{
"compilerOptions": {
"types": ["nuxtswagger/types"]
}
}
and npm run swagger
or npx nuxtswagger
License
ISC License Copyright (c) 2020, Elevista
3.0.0
6 months ago
1.3.2-alpha.0
1 year ago
1.3.1
1 year ago
3.0.0-alpha.0
1 year ago
1.2.3
2 years ago
1.3.0
2 years ago
1.2.0
2 years ago
1.2.2
2 years ago
1.2.1
2 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.1
3 years ago
0.0.1
3 years ago
0.1.0
3 years ago
1.0.0
3 years ago
0.0.1-alpha.4
3 years ago
0.0.1-alpha.3
3 years ago
0.0.1-alpha.2
3 years ago
0.0.1-alpha.1
3 years ago
0.0.1-alpha.0
4 years ago