Options
All
  • Public
  • Public/Protected
  • All
Menu

服务器的配置。

Hierarchy

Index

Properties

Optional dataKey

dataKey: undefined | string

如果接口响应的结果是 JSON 对象, 且我们想要的数据在该对象下, 那我们就可将 dataKey 设为我们想要的数据对应的键。

比如该对象为 { code: 0, msg: '成功', data: 100 }, 我们想要的数据为 100, 则我们可将 dataKey 设为 data

example

'data'

Optional devEnvName

devEnvName: undefined | string

测试环境名称。

用于获取测试环境域名。

获取方式:打开项目 --> 设置 --> 环境配置 --> 点开或新增测试环境 --> 复制测试环境名称。

example

'dev'

Optional outputFilePath

outputFilePath: undefined | string

输出文件路径。

可以是 相对路径绝对路径

example

'src/api/index.ts'

Optional prodEnvName

prodEnvName: undefined | string

生产环境名称。

用于获取生产环境域名。

获取方式:打开项目 --> 设置 --> 环境配置 --> 点开或新增生产环境 --> 复制生产环境名称。

example

'prod'

projects

projects: ProjectConfig[]

项目列表。

Optional reactHooks

reactHooks: ReactHooksConfig

支持生成 React Hooks 代码的相关配置。

Optional requestFunctionFilePath

requestFunctionFilePath: undefined | string

请求函数文件路径。

default

outputFilePath 同级目录下的 request.ts 文件

example

'src/api/request.ts'

serverUrl

serverUrl: string

YApi 服务地址。

example

'http://yapi.foo.bar'

Optional typesOnly

typesOnly: undefined | false | true

是否只生成接口请求内容和返回内容的 TypeSript 类型,是则请求文件和请求函数都不会生成。

default

false

Methods

Optional getRequestDataTypeName

Optional getRequestFunctionName

Optional getResponseDataTypeName

Optional preproccessInterface

  • 预处理接口信息,返回新的接口信息。

    譬如你想对接口的 path 进行某些处理,就可使用该方法。

    example
    interfaceInfo => {
      interfaceInfo.path = interfaceInfo.path.replace('v1', 'v2')
      return interfaceInfo
    }

    Parameters

    Returns Interface

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc