1.0.2 • Published 4 years ago

@dylan92/nemo v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

简体中文

Installing

  npm install @dylan92/nemo
  // or
  yarn add @dylan92/nemo

Example

excute the file below, your will get your swagger typescript files. options:

  1. url: your resultful swagger json url
  2. output: the folder for your swagger typescript files
  3. requestPath: customer request, such as axios, umi-request or file path
  4. exportsRequest: the options for your to decide wether create request folder, always happened when you want save local fetch changes
  5. paths: 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

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.20

4 years ago

0.1.19

4 years ago

0.1.17

4 years ago

0.1.18

4 years ago

0.1.15

4 years ago

0.1.16

4 years ago

0.1.13

4 years ago

0.1.14

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.0.10

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago