0

Currently, my swagger definition has :

"MyAttribute": { "type": "string", "default": "item1", "enum": [ "item1", "item2" ], "xml": { "attribute": true } },

Swagger codegen generates this java code:

@XmlEnum(String.class) public enum MyAttribute{

@XmlEnumValue("item1")
item1("item1"),

@XmlEnumValue("item2")
item2("item2");

private String value;

/**
 * @param value the string representation of the map specification type attribute
 */
MyAttribute(final String value) {
    this.value = value;
}

@Override
public String toString() {

    return String.valueOf(value);
}    

}

Now, I want to have a string array(with values) instead of enum. I tried this (but shows errors on swagger website : http://editor.swagger.io/)

"MyAttribute": { "type": "array", "items": { "type": "string", "values": [ "item1", "item2" ] }, "xml": { "attribute": true } }

How to achieve this?

code_buddy
  • 65
  • 2
  • 12
  • Do you want an array of enum (i.e. array items are enum values), or an _example_ of a multi-item array? – Helen Jun 22 '18 at 12:32
  • I want a multi item array. – code_buddy Jun 22 '18 at 12:41
  • Possible duplicate of [How to add multiple example values in swagger propertise?](https://stackoverflow.com/questions/46578110/how-to-add-multiple-example-values-in-swagger-propertise), also [Return an array of object in SwaggerHub?](https://stackoverflow.com/q/46167981/113116) – Helen Jun 22 '18 at 12:55
  • Thanks for the response. It helped. – code_buddy Jun 22 '18 at 13:10

0 Answers0