简体   繁体   English

将枚举表示为 java Swagger 中的字符串

[英]Represent an enum as a String in java Swagger

I have this object in java with an attribute called type, that represents an enum:我在 java 中有这个 object,它有一个名为 type 的属性,它代表一个枚举:

public class Patch<T> {
   @JsonProperty("path")
   protected String path;
   @JsonProperty("op")
   protected TypeValue op;
   @JsonProperty("value")
   protected T value;
}

This object, when generating a spec in yaml using springfox generates this output when referencing the object TypeValue:这个 object,当使用 springfox 在 yaml 中生成规范时,在引用 ZA8CFDE6331BD59EB2D7C42FZ 时会生成这个 output

 Patch:
type: object
properties:
  op:
    type: string
    enum:
    - add
    - remove
    - replace
    - move
    - copy
  path:
    type: string
  value:
    type: object
    properties: {}
title: Patch

What I want to do is to ignore the enum type when generating the doc, removing the enum type from the spec.我想要做的是在生成文档时忽略枚举类型,从规范中删除枚举类型。 Tis is what I want:这就是我想要的:

Patch:

type: object properties: op: type: string path: type: string value: type: object properties: {} title: Patch类型:object 属性:操作:类型:字符串路径:类型:字符串值:类型:object 属性:{} 标题:补丁

I tried to use the @ApiModelProperty(dataType = "string", allowValues = "A, B, C") but the result is the same我尝试使用 @ApiModelProperty(dataType = "string", allowValues = "A, B, C") 但结果是一样的

How can I do this?我怎样才能做到这一点?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM