swagger io consume json on post -


using swagger editor created post call consume json object want load db when run call empty json object.

this parameters portion of json swagger post

                "parameters": [                 {                     "in": "body",                     "name": "body",                     "description": "add question collection",                     "required": true,                     "schema": { "type" : "object", "additionalproperties" : {}                     }                 }             ], 

it creates "body" model, not able see json part of post:

 @javax.annotation.generated(value = "class io.swagger.codegen.languages.jaxrsservercodegen", date = "2016-01-22t20:49:03.229z") public class body   {       @override   public boolean equals(object o) {     if (this == o) {       return true;     }     if (o == null || getclass() != o.getclass()) {       return false;     }     body body = (body) o;     return true;   }    @override   public int hashcode() {     return objects.hash();   }    @override   public string tostring() {     stringbuilder sb = new stringbuilder();     sb.append("class body {\n");      sb.append("}");     return sb.tostring();   }    /**    * convert given object string each line indented 4 spaces    * (except first line).    */   private string toindentedstring(object o) {     if (o == null) {       return "null";     }     return o.tostring().replace("\n", "\n    ");   } } 

if remove text/json consume , generated code again , still see issue body model , being able pull in json. if @ tostring method shows hard coded values, dont see how can pull json post post method taking in body , securitycontext.

i little confused http accept, when using swagger snippet:

            "post": {             "tags": [                 "askgrey"             ],             "summary": "create new askgrey.com question",             "operationid": "postaskgrey",             "consumes": [                 "application/json",                 "text/json"             ],             "produces": [                 "application/json"             ],             "parameters": [                 {                     "in": "body",                     "name": "body",                     "description": "add question collection",                     "required": true,                     "schema": { "type" : "object", "additionalproperties" : {}                     }                 }             ],             "responses": {                 "200": {                     "description": "ok",                     "schema": {                         "type": "object"                      }                 }             },             "deprecated": false         } 

the method generated following:

      @override   @post   @consumes("application/json")   public response postaskgrey(body body,securitycontext securitycontext)   throws notfoundexception { 

so based on not sure how pull in post body info, grab need http request swagger cant seem figure out how gets used.


Comments