Skip to content

Map support in swagger #1818

@kishoretangudu

Description

@kishoretangudu

I 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"}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions