alibaba/pont

希望有一个关于axios模板的完整demo示例

PeyFon opened this issue · 7 comments

Background(背景)

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
希望有个完整示例,即使是需要自定义的地方也加个示例而不是留下一块空白。对于新手菜鸟有些不太友好。

image
要是没有这示例代码我怎么也想不到inter.response里会有getInitialValue方法,除非我通过ts去翻找Interface

你有完整的demo 吗

你有完整的demo 吗

没有, 代码没看懂理解能力太差, 自己根据公司实际情况从头做了个

@PeyFon 我昨天下班前弄好了

我的实践 重写下面这几个方法 基本实现 自定义输出 代码片段,入口收集 导出

/** 获取接口实现内容的代码 */
getInterfaceContent()

/** 获取单个模块的 index 入口文件 */
  getModIndex()

/** 获取所有模块的 index 入口文件 */
  getModsIndex()

但是遇到一个问题 下面的方法 在 templatePath 文件中不生效

export class MyFileStructures extends FileStructures {
  getParamsCode(className = 'Params', surrounding = Surrounding.typeScript) {
    return `interface ${className} {
      ${this.parameters
        .filter(param => param.in === 'path' || param.in === 'query')
        .map(param => param.toPropertyCode(surrounding, true))
        .join('')}
    }
  `
  }
}

@PeyFon 我昨天下班前弄好了

有链接吗

@PeyFon 我昨天下班前弄好了

有链接吗

没有, 不是仅用swagger去生成的,由于后端技术栈不一样 几乎不能复用