Hi All, @Vivekanathan : If we need to process/map any value in the payload though it is optional we have to know the type when generating the schema. So the sample pay load should not contain null values first place. We need to modify the sample payload with expected values so that in the schema generation we could set the type correctly for that field.
@Sohani : +1 for the above mention approach in the schema generation. One small suggestion to remove the arrow head of type null elements to restrict users from mapping such elements. Thanks, Nuwan On Wed, May 18, 2016 at 11:51 AM, Vivekananthan Sivanayagam < [email protected]> wrote: > Hi Sohani, > > Normally we are getting null value for optional parameter in the API > response, suppose if we get the actual value for that json object , does > this schema handle that case? > > > > > > *Thank youVivekananthan Sivanayagam* > > *Associate Software Engineer | WSO2* > > *E:[email protected] <e%[email protected]>* > *M:+94752786138 <%2B94752786138>* > > On Wed, May 18, 2016 at 11:19 AM, Sohani Weerasinghe <[email protected]> > wrote: > >> Hi All, >> >> If a json payload has null values as shown below, how are we going to >> represent this in the json schema? >> >> { >> "root": { >> "tasklist_id": "12345", >> "test"=null >> } >> } >> >> If we are serializing that value, then the generated schema and the tree >> view will be as follows >> >> { >> "$schema" : "http://json-schema.org/draft-04/schema#", >> "id" : "http://wso2jsonschema.org", >> "title" : "root", >> "type" : "object", >> "properties" : { >> *"test" : {* >> * "id" : "http://wso2jsonschema.org/test >> <http://wso2jsonschema.org/test>",* >> * "type" : "null"* >> * },* >> "tasklist_id" : { >> "id" : "http://wso2jsonschema.org/tasklist_id", >> "type" : "string" >> } >> } >> } >> >> >> >> >> Appreciate your input on this >> >> Thanks, >> Sohani >> Sohani Weerasinghe >> Software Engineer >> WSO2, Inc: http://wso2.com >> >> Mobile : +94 716439774 >> Blog :http://christinetechtips.blogspot.com/ >> Twitter : https://twitter.com/sohanichristine >> > > -- ---------------------------------------------------------- *Nuwan Chamara Pallewela* *Software Engineer* *WSO2, Inc. *http://wso2.com *lean . enterprise . middleware* Email *[email protected] <[email protected]>* Mobile *+94719079739@*
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
