tangcent / easy-yapi

Generate API document to yapi
https://easyyapi.com
GNU Affero General Public License v3.0
439 stars 144 forks source link

当接口请求参数包含一个抽象类字段时如何生成API呢 #1104

Closed yangzan0816 closed 9 months ago

yangzan0816 commented 9 months ago

Describe the question

当前我有一个需求需要在接口中添加一个动态字段,但我不知道如何生成它的api文档

Demo Code 伪代码,我希望能展示出Animal支持的两种参数,请问有实现方案吗 ` public void save(Param param)

class Param{ private TypeEnum type; private Animal animal; }

abstract class Animal{}

class Dog extends Animal{ private BodyShapeEnum bodyShape; } class Bird extends Animal{ private boolean canFly; } `

Additional context

Add any other context about the problem here.

tangcent commented 9 months ago

我之前是这样配置: https://easyyapi.com/qa/field_multiple_types.html 你有更好的想法吗?

yangzan0816 commented 9 months ago

我之前是这样配置: https://easyyapi.com/qa/field_multiple_types.html 你有更好的想法吗?

谢谢,我的问题得到了解决,之前查看文档的时候QA没看仔细漏掉了这个方案,美中不足的是这个方案没有办法在yapi web ui中获取到相应模型的注释,可能提供一个下拉框列表会好一些,我自己尝试一下看看能否做到