1.0.2 • Published 3 years ago
@dylan92/nemo v1.0.2
Installing
npm install @dylan92/nemo
// or
yarn add @dylan92/nemo
Example
excute the file below, your will get your swagger typescript files. options:
url
: your resultful swagger json urloutput
: the folder for your swagger typescript filesrequestPath
: customer request, such asaxios
,umi-request
or file pathexportsRequest
: the options for your to decide wether create request folder, always happened when you want save local fetch changespaths
: exports by paths filter
interface SwaggerConfig {
/**
* @description swagger api url
*/
url: string
/**
* @description single-api or apis
*/
paths?: Array<string | Regexp>
/**
* @description output floder
*/
output?: string
/**
* @description where request module import from
*/
requestPath?: string
/**
* @description request templates only create and remove when it is true
* when you only need exportsRequest once, mostly code likes:
* * `exportsRequest: !isRequestFloderExsit`
*/
exportsRequest?: boolean
}
const main = require('@dylan92/nemo')
// with esm
import main from '@dylan92/nemo'
main({
url: 'https://petstore.swagger.io/v2/swagger.json',
output: './src/core/test'
})
It easy for you to use other request library. Example:
type RequestInitWithoutBodyInit = Omit<RequestInit, 'body'>
interface Options extends RequestInitWithoutBodyInit, Record<string, any> {
body?: Record<string, any>
formData?: Record<string, any>
query?: Record<string, any>
}
// default request
request<ResponseType>(url: string, options: Options)
// your request file
import fetch from `${library}`
import { getRequestBody, Options } from `${output}/utils`
export default async function <T>(url, options) {
const body: BodyInit | undefined = getRequestBody(options)
const data = await request<T>(url, Object.assign(options, {body}))
return data
}
TODO
- terminal tool
- bin tests
- swagger v3 support
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago
0.1.20
3 years ago
0.1.19
3 years ago
0.1.17
3 years ago
0.1.18
3 years ago
0.1.15
3 years ago
0.1.16
3 years ago
0.1.13
3 years ago
0.1.14
3 years ago
0.1.12
3 years ago
0.1.11
3 years ago
0.1.10
3 years ago
0.1.9
3 years ago
0.1.8
3 years ago
0.1.7
3 years ago
0.1.6
3 years ago
0.1.5
3 years ago
0.1.4
3 years ago
0.1.3
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.0.10
3 years ago
0.1.0
3 years ago
0.0.9
3 years ago
0.0.8
3 years ago
0.0.7
3 years ago
0.0.6
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago