Hi,

IMO, As Nuwan said, generating the schema without null is the best way.
Since there may be chances to get values for those nullable fields. So we
will create the schema by replacing possible values for the null as shown
in [1]. Currently we replace those nulls with string values.

The problem in this approach is; It is difficult to find the types of
all response
fields. Since they don't document all response fields. So we can guess from
the name of the field or some APIs provide sample response.

It should not allow to map with another one, in case the field in the
actual response is null.

[1]

Response Payload:

{
 "id": 731513399901851600,
 "name": "Josh",
 "message":null,
 "isProtected":null
}

Modified Payload:

{
 "id": 731513399901851600,
 "name": "Josh",
 "message":"Test Message",
 "isProtected":true
}


Thanks

On Wed, May 18, 2016 at 1:31 PM, Nuwan Pallewela <nuw...@wso2.com> wrote:

> Hi Malaka,
>
> Yes. We may have to refer api docs and find the expected value for those
> optional fields and in the esb runtime data mapper engine should handle
> them. But the engine is not implemented up-to that level yet. We should
> handle these null-able fields.
>
> Thanks,
> Nuwan
>
> On Wed, May 18, 2016 at 12:07 PM, Malaka Silva <mal...@wso2.com> wrote:
>
>> Actually those are options for the given configuration. We don't really
>> have a clear idea what are the optional response elements. (Unless we refer
>> api docs)
>>
>> So I guess we can proceed with sample values.
>>
>> From datamapper mediator(ESB Side) level we need to handle if we receive
>> a null value. Guess this is already considered?
>>
>> On Wed, May 18, 2016 at 12:02 PM, Sohani Weerasinghe <soh...@wso2.com>
>> wrote:
>>
>>>
>>>
>>> Sohani Weerasinghe
>>> Software Engineer
>>> WSO2, Inc: http://wso2.com
>>>
>>> Mobile  : +94 716439774
>>> Blog     :http://christinetechtips.blogspot.com/
>>> Twitter  : https://twitter.com/sohanichristine
>>>
>>> On Wed, May 18, 2016 at 12:00 PM, Nuwan Pallewela <nuw...@wso2.com>
>>> wrote:
>>>
>>>> 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.
>>>>
>>>
>>> Will do.
>>>
>>>>
>>>> Thanks,
>>>> Nuwan
>>>>
>>>> On Wed, May 18, 2016 at 11:51 AM, Vivekananthan Sivanayagam <
>>>> vivekanant...@wso2.com> 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:vivekanant...@wso2.com <e%3avivekanant...@wso2.com>*
>>>>> *M:+94752786138 <%2B94752786138>*
>>>>>
>>>>> On Wed, May 18, 2016 at 11:19 AM, Sohani Weerasinghe <soh...@wso2.com>
>>>>> 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   *nuw...@wso2.com <nuw...@wso2.com>*
>>>> Mobile  *+94719079739 <%2B94719079739>@*
>>>>
>>>>
>>>>
>>>
>>
>>
>> --
>>
>> Best Regards,
>>
>> Malaka Silva
>> Senior Tech Lead
>> M: +94 777 219 791
>> Tel : 94 11 214 5345
>> Fax :94 11 2145300
>> Skype : malaka.sampath.silva
>> LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
>> Blog : http://mrmalakasilva.blogspot.com/
>>
>> WSO2, Inc.
>> lean . enterprise . middleware
>> http://www.wso2.com/
>> http://www.wso2.com/about/team/malaka-silva/
>> <http://wso2.com/about/team/malaka-silva/>
>> https://store.wso2.com/store/
>>
>> Save a tree -Conserve nature & Save the world for your future. Print this
>> email only if it is absolutely necessary.
>>
>
>
>
> --
> ----------------------------------------------------------
>
> *Nuwan Chamara Pallewela*
>
>
> *Software Engineer*
>
> *WSO2, Inc. *http://wso2.com
> *lean . enterprise . middleware*
>
> Email   *nuw...@wso2.com <nuw...@wso2.com>*
> Mobile  *+94719079739 <%2B94719079739>@*
>
>
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Shakila Sivagnanarajah
Associate Software Engineer
Mobile :+94 (0) 768 856837
shak...@wso2.com
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to