Map support in swagger
See original GitHub issueI have input to my rest API below:
{ “a”:“value”, “resources”: {“key1”:“value1”, “key2”:“value2” } } When I am doing
class MyModelClass { @XmlElement(name = “resources”) @ApiModelProperty(value = “resources”) Map<String, MYClass> resources= new HashMap<String,MyClass>();
//Setters and getters for resource object. }
Now
public class MyClass{
@XmlTransient
JSONObject pushnotificationResources = new JSONObject();
public JSONObject getPushnotificationResources() {
return pushnotificationResources;
}
public void setPushnotificationResources(JSONObject pushnotificationResources) {
this.pushnotificationResources = pushnotificationResources;
}
}
when I am loading my application I am getting the below error: Can not instantiate value of type [simple type, class packagename.MYClass] from String value; no single-String constructor/factory method (through reference chain: com.tycoon.auth.idm.identity.model.MYModelClass[“resources”])
Please help me to accept a json object with key value pairs as part of an attribute value? like below {“resource”: {“k1”:“v1”,“k2”,“v2”}}
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
Simply override the
dataTypefor yourJSONObjectvalue like such:Then your definition looks like it accepts a
Map<String, Object>:Hi, please take a look at the swagger-samples project for integration examples.