小编chi*_*uan的帖子

JsonTypeInfo.As.WRAPPER_OBJECT 是否有 swagger.json 标记?

我有 2 个应用程序,其中应用程序 A 公开 API 供应用程序 B 使用。

应用程序 A 正在为应用程序 B 生成 swagger.json,应用程序 B 正在使用 swagger-codegen 生成模型代码。

在我的应用程序 A 中,它使用 Jackson 和 WRAPPER_OBJECT 进行多态处理

@JsonTypeInfo (use = JsonTypeInfo.Id.NAME, include = 
JsonTypeInfo.As.WRAPPER_OBJECT, property = "type")
@JsonSubTypes({@JsonSubTypes.Type(value = Dog.class, name = "doggy"), 
@JsonSubTypes.Type(value = Cat.class, name = "kitty")})
@ApiModel(subTypes = {Dog.class, Cat.class}, discriminator = "type")
public abstract class Animal {
}

@ApiModel(value = "kitty", parent = Animal.class)
public class Cat extends Animal {
    public int lives = 9;
}

@ApiModel(value …
Run Code Online (Sandbox Code Playgroud)

java json jackson swagger openapi

5
推荐指数
0
解决办法
1631
查看次数

标签 统计

jackson ×1

java ×1

json ×1

openapi ×1

swagger ×1