Pedro Almeida
Pedro Almeida

Reputation: 81

Represent an enum as a String in java Swagger

I have this object in java with an attribute called type, that represents an enum:

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:

 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

I tried to use the @ApiModelProperty(dataType = "string", allowValues = "A, B, C") but the result is the same

How can I do this?

Upvotes: 0

Views: 345

Answers (1)

Related Questions