Manweill / swagger-axios-codegen

swagger client to use axios and typescript
MIT License
306 stars 83 forks source link

请问swagger 返回Class 定义是泛型类时 应该怎么处理? #45

Closed xxbld closed 5 years ago

xxbld commented 5 years ago

Return«List«DictionaryTypeEntity»» 特殊字符.

Manweill commented 5 years ago

目前关于泛型的处理是,如果识别出类名是含有[]包裹着的就是泛型。对应你这个类型可能是 Return[List[DictonaryTypeEntity]] 然后会正常识别出泛型,但是也是会转成普通的类型 Retrun_List_DictionaryTypeEntity。目前泛型没有更好的方案。 你这个情况的话,可能需要把 «» 变成 [],或者生成器针对 «» 来做优化就可以了。 如果要完美支持泛型,需要在生成之前就定义好,对应的泛型类。因为生成器是不知道 Return<T>中的 T 是给到 Return 中的哪个属性

xxbld commented 5 years ago

我提交了一个pr判断«» 为泛型; 我打算把Pont里面中文翻译功能挪进来,你觉得有必要不? image

Manweill commented 5 years ago

这个翻译是怎么得来的

xxbld commented 5 years ago

translation.js 实现是我从Pont搞的.

Manweill commented 5 years ago

应该不用吧,实际场景中,中文的类型这些应该不存在。。。

Manweill commented 5 years ago

还有,我想请教一下,«» 这个符号是由什么生成器输出的,什么语言的

xxbld commented 5 years ago

应该不用吧,实际场景中,中文的类型这些应该不存在。。。

就是有的后台给实体名swagger输出改成中文了,controller的tag也用中文。就比较无语了

还有,我想请教一下,«» 这个符号是由什么生成器输出的,什么语言的

就是java swagger的2.0

Manweill commented 5 years ago

是不是你用的swagger的包有不对呢,我看过其他的java的包没有这个会这样

xxbld commented 5 years ago

可能跟版本有关 https://github.com/Manweill/swagger-axios-codegen/issues/22#issue-440405645 这位兄弟也是跟我一样的字符 近期可以更新一个版本嘛?

Manweill commented 5 years ago

可以,这两天我还有个参数优化要发。

xxbld commented 5 years ago

useCustomerRequestInstance: true 这个参数出来的代码不太对

xxbld commented 5 years ago

useCustomerRequestInstance: true 这个参数出来的代码不太对

@Manweill

Manweill commented 5 years ago

你倒是说哪里不对啊,有问题直接说明白好白,问来问去很浪费时间的

xxbld commented 5 years ago

你倒是说哪里不对啊,有问题直接说明白好白,问来问去很浪费时间的

之前有点忙没仔细看,想用到小程序上,就测试了一下结果报错了

https://github.com/Manweill/swagger-axios-codegen/pull/52

Manweill commented 5 years ago

@xxbld 小程序上,不能用axios,要换成fly.js

xxbld commented 5 years ago

@xxbld 小程序上,不能用axios,要换成fly.js

嗯,就是因为这个才测试的useCustomerRequestInstance