nuxtswagger
NuxTSwagger
Nuxt-TS-Swagger plugin generator CLI
Installation
npm i -D nuxtswagger
Requirements
Nuxtbase project
Basic Usage
in Nuxt project directory
npx nuxtswagger https://api.server.foo/swagger.json
in script code
import { api } from '~/lib/api'
const response = await api.foo.bar(1).post(requestBody) // Post /foo/{bar}
api.foo.bar.get() // GET /foo/bar
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 |
|
export-name |
Export name | {plugin-name} |
''(export default) |
type-path |
Path for scheme type file | {plugins-dir}/{plugin-name}/{types.ts} |
./types/swagger.d.ts |
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
Related Packages
nuxt-define
One utility function for module authors to define compiler constants for all bui...
13,412,511
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 3.0.0 | ISC | ||
| 1.3.1 | ISC | ||
| 1.3.0 | ISC | ||
| 1.2.3 | ISC | ||
| 1.2.2 | ISC | ||
| 1.1.1 | ^2.6.12 | ISC | |
| 1.0.1 | ^2.6.12 | ISC | |
| 1.0.0 | ^2.6.12 | ISC | |
| 0.1.0 | ^2.6.12 | ISC |
Pre-releases (13)
| Version | Released | Vue | License |
|---|---|---|---|
| 3.0.1-5 | ISC | ||
| 3.0.1-4 | ISC | ||
| 3.0.1-3 | ISC | ||
| 3.0.1-2 | ISC | ||
| 3.0.1-1 | ISC | ||
| 3.0.1-0 | ISC | ||
| 3.0.0-alpha.0 | ISC | ||
| 1.3.2-alpha.0 | ISC | ||
| 0.0.1-alpha.4 | ^2.6.12 | ISC | |
| 0.0.1-alpha.3 | ^2.6.12 | ISC | |
| 0.0.1-alpha.2 | ^2.6.12 | ISC | |
| 0.0.1-alpha.1 | ^2.6.12 | ISC | |
| 0.0.1-alpha.0 | ISC |