Implemented above scenarios (also mentioned in [1]) in schema generation. [1] - https://docs.google.com/a/wso2.com/document/d/1s820PSZlhRYq8kGc9GFwJaMcpQX8X4jz9sFvo1bK6rI/edit?usp=sharing
On Tue, Apr 12, 2016 at 3:06 PM, Sohani Weerasinghe <[email protected]> wrote: > Hi All, > > Please find below details on the support provided in defining the data > types for objects( when holding values) in JSON schema. > > Problem: > > When an object array or a primitive array or an object holds a value, > there should be a way to define the data type of that value in the schema. > > <h:person xmlns:h="http://www.w3.org/TR/html4/"> > <firstName>sample</firstName> > <phone primary="true">*0717777771* <0717777771><ext> > 01</ext></phone> > <phone primary="false">*0112655655* <0112655655><ext>01</ext></phone> > </h:person> > > Solution: > > We have introduced an object called "value" as below in defining the data > type > > "value":{ > "type": "number" > } > > 1. An object array with attributes, properties and values > > <h:person xmlns:h="http://www.w3.org/TR/html4/"> > <firstName>sample</firstName> > <phone primary="false"> > 0112655655 > <ext>01</ext> > </phone> > <phone primary="false"> > 0112655655 > <ext>01</ext> > </phone> > </h:person> > > { > "$schema":"http://json-schema.org/draft-04/schema#", > "title":"person", > "id":"http://wso2jsonschema.org", > "type":"object", > "properties":{ > "firstName":{ > "id":"http://wso2jsonschema.org/firstName", > "type":"string" > }, > "phone":{ > "id":"http://wso2jsonschema.org/phone", > "type":"array", > "items":[ > { > "id":"http://wso2jsonschema.org/phone/0", > "type":"object", > * "value":{ * > * "type":"number"* > * },* > "properties":{ > "ext":{ > "id":"http://wso2jsonschema.org/phone/0/ext", > "type":"number" > } > }, > "attributes":{ > "primary":{ > "id":"http://wso2jsonschema.org/phone/0/primary", > "type":"boolean" > } > } > } > ] > } > } > } > > 2. Primitive array with values > > <person> > <firstName>sample</firstName> > <phone>0112655655</phone> > <phone>0112655656</phone> > </person> > > { > "$schema":"http://json-schema.org/draft-04/schema#", > "title":"person", > "id":"http://wso2jsonschema.org", > "type":"object", > "properties":{ > "firstName":{ > "id":"http://wso2jsonschema.org/firstName", > "type":"string" > }, > "phone":{ > "id":"http://wso2jsonschema.org/phone", > "type":"array", > "items":[ > { > * "id":"http://wso2jsonschema.org/phone/phone > <http://wso2jsonschema.org/phone/phone>",* > * "type":"number"* > } > ] > } > } > } > > 3. Object with values > > <person> > <firstName>sample</firstName> > <phone primary="true">071655339</phone> > </person> > > { > "$schema":"http://json-schema.org/draft-04/schema#", > "title":"person", > "id":"http://wso2jsonschema.org", > "type":"object", > "properties":{ > "firstName":{ > "id":"http://wso2jsonschema.org/firstName", > "type":"string" > }, > "phone":{ > "id":"http://wso2jsonschema.org/phone", > "type":"object", > * "value":{ * > * "type":"number"* > * },* > "attributes":{ > "primary":{ > "id":"http://wso2jsonschema.org/primary", > "type":"boolean" > } > } > } > } > > Thanks, > Sohani > Sohani Weerasinghe > Software Engineer > WSO2, Inc: http://wso2.com > > Mobile : +94 716439774 > Blog :http://christinetechtips.blogspot.com/ > Twitter : https://twitter.com/sohanichristine > -- *Susinda Perera* Software Engineer B.Sc.(Eng), M.Sc(Computer Science), AMIE(SL) Mobile:(+94)716049075 Blog: susinda.blogspot.com WSO2 Inc. http://wso2.com/ Tel : 94 11 214 5345 Fax :94 11 2145300
_______________________________________________ Architecture mailing list [email protected] https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
