1 /******************************************************************
\r
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
19 ******************************************************************/
\r
22 * @file JsonSchema.cpp
\r
24 * @brief This file reads data from Json Schema.
\r
27 #include "JsonSchema.h"
\r
32 void JsonSchema::readJson()
\r
37 cJSON *jsonId = cJSON_GetObjectItem(m_cjson, "id");
\r
40 m_id = jsonId->valuestring;
\r
42 cJSON *jsonSchema = cJSON_GetObjectItem(m_cjson, "$schema");
\r
45 m_schema = jsonSchema->valuestring;
\r
47 cJSON *jsonTitle = cJSON_GetObjectItem(m_cjson, "title");
\r
50 m_title = jsonTitle->valuestring;
\r
52 cJSON *jsonType = cJSON_GetObjectItem(m_cjson, "type");
\r
55 m_type = jsonType->valuestring;
\r
57 cJSON *jsonDescription = cJSON_GetObjectItem(m_cjson, "description");
\r
58 if (jsonDescription)
\r
60 m_description = jsonDescription->valuestring;
\r
62 cJSON *jsonDefinitions = cJSON_GetObjectItem(m_cjson, "definitions");
\r
63 if (jsonDefinitions)
\r
65 cJSON *childDefinitions = jsonDefinitions->child;
\r
66 while (childDefinitions)
\r
68 std::string defName = childDefinitions->string;
\r
69 addDefinition(defName, readDef(childDefinitions, defName));
\r
70 childDefinitions = childDefinitions->next;
\r
73 cJSON *jsonProperties = cJSON_GetObjectItem(m_cjson, "properties");
\r
76 cJSON *childProperties = jsonProperties->child;
\r
77 while (childProperties)
\r
79 std::string attName = childProperties->string;
\r
80 addProperty(attName, readProp(childProperties, attName));
\r
81 childProperties = childProperties->next;
\r
84 if (m_type == "array")
\r
86 PropertiesPtr property = std::make_shared<Properties>("array");
\r
87 readArray(m_cjson, property);
\r
88 addProperty("array" , property);
\r
91 cJSON *jsonAdditionalProperties = cJSON_GetObjectItem(m_cjson, "additionalProperties");
\r
92 if (jsonAdditionalProperties)
\r
93 m_additionalProperties = jsonAdditionalProperties->type;
\r
95 m_additionalProperties = cJSON_True;
\r
97 cJSON *jsonReference = cJSON_GetObjectItem(m_cjson, "$ref");
\r
100 JsonParameters param;
\r
101 readJsonRef(jsonReference, param);
\r
103 for (auto it : param.getProperties())
\r
105 addProperty(it.first, it.second);
\r
107 for ( auto it : param.getRequired())
\r
109 setRequiredValue(it);
\r
111 if (m_type.empty())
\r
112 m_type = param.getType();
\r
114 cJSON *jsonAllOf = cJSON_GetObjectItem(m_cjson, "allOf");
\r
117 JsonParameters param;
\r
119 readAllOf(jsonAllOf, param);
\r
121 for (auto it : param.getProperties())
\r
123 addProperty(it.first, it.second);
\r
125 for ( auto it : param.getRequired())
\r
127 setRequiredValue(it);
\r
129 if (m_type.empty())
\r
130 m_type = param.getType();
\r
132 cJSON *jsonRequiredValues = cJSON_GetObjectItem(m_cjson, "required");
\r
133 if (jsonRequiredValues)
\r
135 int size = cJSON_GetArraySize(jsonRequiredValues);
\r
139 setRequiredValue(cJSON_GetArrayItem(jsonRequiredValues, index)->valuestring);
\r
141 while ( ++index < size);
\r
145 DefinitionsPtr JsonSchema::readDef(cJSON *childDefinitions, const std::string &defName)
\r
147 DefinitionsPtr definition = std::make_shared<Definitions>(defName);
\r
149 cJSON *defType = cJSON_GetObjectItem(childDefinitions, "type");
\r
152 std::string type = defType->valuestring;
\r
153 definition->setType(type);
\r
154 if (type == "array")
\r
156 PropertiesPtr property = std::make_shared<Properties>("array");
\r
157 readArray(childDefinitions, property);
\r
158 definition->addProperty("array" , property);
\r
161 cJSON *defProperties = cJSON_GetObjectItem(childDefinitions, "properties");
\r
164 cJSON *childProperties = defProperties->child;
\r
165 while (childProperties)
\r
167 std::string attName = childProperties->string;
\r
168 definition->addProperty(attName, readProp(childProperties, attName));
\r
169 childProperties = childProperties->next;
\r
172 cJSON *defRequiredValues = cJSON_GetObjectItem(childDefinitions, "required");
\r
173 if (defRequiredValues)
\r
175 int size = cJSON_GetArraySize(defRequiredValues);
\r
179 definition->setRequiredValue(cJSON_GetArrayItem(defRequiredValues, index)->valuestring);
\r
181 while ( ++index < size);
\r
183 cJSON *defReference = cJSON_GetObjectItem(childDefinitions, "$ref");
\r
186 JsonParameters param;
\r
187 readJsonRef(defReference, param);
\r
189 for (auto it : param.getProperties())
\r
191 definition->addProperty(it.first, it.second);
\r
193 for ( auto it : param.getRequired())
\r
195 definition->setRequiredValue(it);
\r
197 if (definition->getType().empty())
\r
198 definition->setType(param.getType());
\r
200 cJSON *defAllOf = cJSON_GetObjectItem(childDefinitions, "allOf");
\r
203 JsonParameters param;
\r
204 readAllOf(defAllOf, param);
\r
206 for (auto it : param.getProperties())
\r
208 definition->addProperty(it.first, it.second);
\r
210 for ( auto it : param.getRequired())
\r
212 definition->setRequiredValue(it);
\r
214 if (definition->getType().empty())
\r
215 definition->setType(param.getType());
\r
220 PropertiesPtr JsonSchema::readProp(cJSON *childProperties, const std::string &attName )
\r
222 PropertiesPtr property = std::make_shared<Properties>(attName);
\r
224 cJSON *propertyDescription = cJSON_GetObjectItem(childProperties, "description");
\r
225 if (propertyDescription)
\r
227 property->setDescription(propertyDescription->valuestring);
\r
229 cJSON *propertyType = cJSON_GetObjectItem(childProperties, "type");
\r
230 std::string attType;
\r
233 if (propertyType->type == 4)
\r
235 attType = propertyType->valuestring;
\r
237 else if (propertyType->type == 5)
\r
239 attType = cJSON_GetArrayItem(propertyType, 0)->valuestring;
\r
242 if (!(attType == "array") && !(attType == "object"))
\r
244 cJSON *defaultValue = cJSON_GetObjectItem(childProperties, "default");
\r
247 readDefaultValue(defaultValue, property, attType);
\r
250 readValues(childProperties, property, attType);
\r
251 cJSON *allowedvalues = cJSON_GetObjectItem(childProperties, "enum");
\r
254 readAllowedValues(allowedvalues, property, attType);
\r
256 property->setTypeString(attType);
\r
260 void JsonSchema::readDefaultValue(cJSON *defaultValue, PropertiesPtr &property,
\r
261 const std::string &attType)
\r
263 if (defaultValue->type == 4)
\r
265 property->setValue((std::string)defaultValue->valuestring);
\r
267 else if (defaultValue->type == 3)
\r
269 if (attType == "number")
\r
270 property->setValue((double)defaultValue->valuedouble);
\r
272 property->setValue((int)defaultValue->valueint );
\r
274 else if (defaultValue->type == 1)
\r
276 property->setValue((bool)true);
\r
278 else if (defaultValue->type == 0)
\r
280 property->setValue((bool)false);
\r
284 void JsonSchema::readAllowedValues(cJSON *allowedvalues, PropertiesPtr &property,
\r
285 std::string &attType)
\r
287 if ((cJSON_GetArrayItem(allowedvalues, 0)->type) == 4)
\r
289 int size = cJSON_GetArraySize(allowedvalues);
\r
291 std::vector<std::string> allwdValues;
\r
294 allwdValues.push_back(cJSON_GetArrayItem(allowedvalues, idx)->valuestring);
\r
296 while ( ++idx < size);
\r
297 property->setValueProperty(std::make_shared<ValueProperty>(allwdValues));
\r
298 if (attType.empty())
\r
299 attType = "string";
\r
301 else if ((cJSON_GetArrayItem(allowedvalues, 0)->type) == 3)
\r
303 int size = cJSON_GetArraySize(allowedvalues);
\r
305 if (attType == "number")
\r
307 std::vector<double> allwdValues;
\r
310 allwdValues.push_back(cJSON_GetArrayItem(allowedvalues, idx)->valuedouble);
\r
312 while ( ++idx < size);
\r
313 property->setValueProperty(std::make_shared<ValueProperty>(allwdValues));
\r
317 std::vector<int> allwdValues;
\r
320 allwdValues.push_back(cJSON_GetArrayItem(allowedvalues, idx)->valueint);
\r
322 while ( ++idx < size);
\r
323 property->setValueProperty(std::make_shared<ValueProperty>(allwdValues));
\r
324 if (attType.empty())
\r
325 attType = "integer";
\r
328 else if (((cJSON_GetArrayItem(allowedvalues, 0)->type) == 1)
\r
329 || ((cJSON_GetArrayItem(allowedvalues, 0)->type) == 0))
\r
331 int size = cJSON_GetArraySize(allowedvalues);
\r
333 std::vector<bool> allwdValues;
\r
336 if (cJSON_GetArrayItem(allowedvalues, idx)->type)
\r
337 allwdValues.push_back(true);
\r
339 allwdValues.push_back(false);
\r
341 while ( ++idx < size);
\r
342 property->setValueProperty(std::make_shared<ValueProperty>(allwdValues));
\r
343 if (attType.empty())
\r
344 attType = "boolean";
\r
348 void JsonSchema::readValues(cJSON *childProperties, PropertiesPtr &property ,
\r
349 const std::string &attType)
\r
351 if (attType == "string")
\r
353 readString(childProperties, property);
\r
355 else if (attType == "integer")
\r
357 readInteger(childProperties, property);
\r
359 else if (attType == "number")
\r
361 readDouble(childProperties, property);
\r
363 else if (attType == "array")
\r
365 readArray(childProperties, property);
\r
367 else if (attType == "object")
\r
369 readObject(childProperties, property);
\r
373 void JsonSchema::readString(cJSON *childProperties, PropertiesPtr &property)
\r
375 cJSON *stringMax = cJSON_GetObjectItem(childProperties, "maxLength");
\r
376 int min = INT_MIN, max = INT_MAX;
\r
379 cJSON *exclusiveMax = cJSON_GetObjectItem(childProperties, "exclusiveMaximum");
\r
382 if (exclusiveMax->type == cJSON_True)
\r
383 max = --(stringMax->valueint);
\r
385 max = stringMax->valueint;
\r
388 max = stringMax->valueint;
\r
390 cJSON *stringMin = cJSON_GetObjectItem(childProperties, "minLength");
\r
393 cJSON *exclusiveMin = cJSON_GetObjectItem(childProperties, "exclusiveMinimum");
\r
396 if (exclusiveMin->type == cJSON_True)
\r
397 min = ++(stringMin->valueint);
\r
399 min = stringMin->valueint;
\r
402 min = stringMin->valueint;
\r
404 if (min != INT_MIN || max != INT_MAX)
\r
405 property->setValueProperty(std::make_shared<ValueProperty>(min, max, 0));
\r
407 cJSON *stringFormat = cJSON_GetObjectItem(childProperties, "format");
\r
410 property->setValueProperty(std::make_shared<ValueProperty>
\r
411 (ValueProperty::Type::FORMAT, (stringFormat->valuestring)));
\r
414 cJSON *stringPattern = cJSON_GetObjectItem(childProperties, "pattern");
\r
417 property->setValueProperty(std::make_shared<ValueProperty>
\r
418 (ValueProperty::Type::PATTERN, (stringPattern->valuestring)));
\r
422 void JsonSchema::readInteger(cJSON *childProperties, PropertiesPtr &property)
\r
424 cJSON *Max = cJSON_GetObjectItem(childProperties, "maximum");
\r
425 int min = INT_MIN, max = INT_MAX, multipleOf = INT_MAX;
\r
428 cJSON *exclusiveMax = cJSON_GetObjectItem(childProperties, "exclusiveMaximum");
\r
431 if (exclusiveMax->type == cJSON_True)
\r
432 max = --(Max->valueint);
\r
434 max = Max->valueint;
\r
437 max = Max->valueint;
\r
439 cJSON *Min = cJSON_GetObjectItem(childProperties, "minimum");
\r
442 cJSON *exclusiveMin = cJSON_GetObjectItem(childProperties, "exclusiveMinimum");
\r
445 if (exclusiveMin->type == cJSON_True)
\r
446 min = ++(Min->valueint);
\r
448 min = Min->valueint;
\r
451 min = Min->valueint;
\r
453 cJSON *MultipleOff = cJSON_GetObjectItem(childProperties, "multipleOf");
\r
456 multipleOf = MultipleOff->valueint;
\r
458 if (min != INT_MIN || max != INT_MAX)
\r
459 property->setValueProperty(std::make_shared<ValueProperty>(min, max, multipleOf));
\r
463 void JsonSchema::readDouble(cJSON *childProperties, PropertiesPtr &property)
\r
465 cJSON *Max = cJSON_GetObjectItem(childProperties, "maximum");
\r
466 double min = INT_MIN, max = INT_MAX;
\r
467 int multipleOf = INT_MAX;
\r
470 cJSON *exclusiveMax = cJSON_GetObjectItem(childProperties, "exclusiveMaximum");
\r
473 if (exclusiveMax->type == cJSON_True)
\r
474 max = --(Max->valuedouble);
\r
476 max = Max->valuedouble;
\r
479 max = Max->valuedouble;
\r
481 cJSON *Min = cJSON_GetObjectItem(childProperties, "minimum");
\r
484 cJSON *exclusiveMin = cJSON_GetObjectItem(childProperties, "exclusiveMinimum");
\r
487 if (exclusiveMin->type == cJSON_True)
\r
488 min = ++(Min->valuedouble);
\r
490 min = Min->valuedouble;
\r
493 min = Min->valuedouble;
\r
496 cJSON *MultipleOff = cJSON_GetObjectItem(childProperties, "multipleOf");
\r
499 multipleOf = MultipleOff->valueint;
\r
501 if (min != INT_MIN || max != INT_MAX)
\r
502 property->setValueProperty(std::make_shared<ValueProperty>(min, max, multipleOf));
\r
506 void JsonSchema::readArray(cJSON *childProperties, PropertiesPtr &property)
\r
508 cJSON *itemValues = cJSON_GetObjectItem(childProperties, "items");
\r
511 if (itemValues->type == 5)
\r
513 //int item_size = cJSON_GetArraySize(itemValues);
\r
514 int item_index = 0;
\r
517 cJSON *item = cJSON_GetArrayItem(itemValues, item_index);
\r
518 readItems(item, property);
\r
521 //while ( ++item_index < item_size);
\r
525 readItems(itemValues, property);
\r
528 cJSON *itemsMax = cJSON_GetObjectItem(childProperties, "maxItems");
\r
529 int min = INT_MIN, max = INT_MAX;
\r
530 bool unique = cJSON_False, addItems = cJSON_False;
\r
533 cJSON *exclusiveMax = cJSON_GetObjectItem(childProperties, "exclusiveMaximum");
\r
536 if (exclusiveMax->type == cJSON_True)
\r
537 max = --(itemsMax->valueint);
\r
539 max = itemsMax->valueint;
\r
542 max = itemsMax->valueint;
\r
544 cJSON *itemsMin = cJSON_GetObjectItem(childProperties, "minItems");
\r
547 cJSON *exclusiveMin = cJSON_GetObjectItem(childProperties, "exclusiveMinimum");
\r
550 if (exclusiveMin->type == cJSON_True)
\r
551 min = ++(itemsMin->valueint);
\r
553 min = itemsMin->valueint;
\r
556 min = itemsMin->valueint;
\r
558 cJSON *uniqueItems = cJSON_GetObjectItem(childProperties, "uniqueItems");
\r
561 unique = uniqueItems->type;
\r
563 cJSON *additionalItems = cJSON_GetObjectItem(childProperties, "additionalItems");
\r
564 if (additionalItems)
\r
566 addItems = additionalItems->type;
\r
568 property->setValueProperty(std::make_shared<ValueProperty>
\r
569 (ValueProperty::Type::ARRAY, min, max, unique, addItems));
\r
572 void JsonSchema::readItems(cJSON *item, PropertiesPtr &property)
\r
575 JsonParameters param;
\r
576 cJSON *itemType = cJSON_GetObjectItem(item, "type");
\r
579 type = itemType->valuestring;
\r
582 cJSON *itemAllOf = cJSON_GetObjectItem(item, "allOf");
\r
585 readAllOf(itemAllOf , param);
\r
589 cJSON *itemOneOf = cJSON_GetObjectItem(item, "oneOf");
\r
592 readAllOf(itemOneOf , param);
\r
596 cJSON *itemReference = cJSON_GetObjectItem(item, "$ref");
\r
599 readJsonRef(itemReference , param);
\r
602 if (type == "object")
\r
604 cJSON *itemProperties = cJSON_GetObjectItem(item, "properties");
\r
605 if (itemProperties)
\r
607 cJSON *childProperties = itemProperties->child;
\r
608 std::vector<Properties> propertyVector;
\r
609 while (childProperties)
\r
611 std::string attName = childProperties->string;
\r
612 PropertiesPtr prop = std::make_shared<Properties>(attName);
\r
613 readProp(childProperties, attName);
\r
614 propertyVector.push_back(*prop);
\r
615 childProperties = childProperties->next;
\r
617 property->setValue(propertyVector);
\r
620 cJSON *itemRequiredValues = cJSON_GetObjectItem(item, "required");
\r
621 if (itemRequiredValues)
\r
623 int size = cJSON_GetArraySize(itemRequiredValues);
\r
627 property->setRequiredValue(cJSON_GetArrayItem(itemRequiredValues, index)->valuestring);
\r
629 while ( ++index < size);
\r
633 else if (param.getType() == "object")
\r
635 std::vector<Properties> propertyVector;
\r
636 for (auto prop : param.getProperties())
\r
638 propertyVector.push_back(*(prop.second));
\r
640 property->setValue(propertyVector);
\r
642 for (auto req : param.getRequired())
\r
644 property->setRequiredValue(req);
\r
649 PropertiesPtr prop = std::make_shared<Properties>("property");
\r
651 cJSON *defaultValue = cJSON_GetObjectItem(item, "default");
\r
654 readDefaultValue(defaultValue, prop, type);
\r
656 cJSON *allowedvalues = cJSON_GetObjectItem(item, "enum");
\r
659 readAllowedValues(allowedvalues, prop, type);
\r
661 readValues(item, prop, type);
\r
662 prop->setTypeString(type);
\r
663 property->setValue(*prop);
\r
667 void JsonSchema::readObject(cJSON *childProperties, PropertiesPtr &property)
\r
669 property->setTypeString("object");
\r
671 cJSON *subProperties = cJSON_GetObjectItem(childProperties, "properties");
\r
672 cJSON *itemRequiredValues = cJSON_GetObjectItem(childProperties, "required");
\r
675 cJSON *childProperties = subProperties->child;
\r
676 std::vector<Properties> propertyVector;
\r
677 while (childProperties)
\r
679 std::string attName = childProperties->string;
\r
680 PropertiesPtr prop = std::make_shared<Properties>(attName);
\r
681 readProp(childProperties, attName);
\r
682 propertyVector.push_back(*prop);
\r
683 childProperties = childProperties->next;
\r
685 property->setValue(propertyVector);
\r
686 if (itemRequiredValues)
\r
688 int size = cJSON_GetArraySize(itemRequiredValues);
\r
692 property->setRequiredValue(cJSON_GetArrayItem(itemRequiredValues, index)->valuestring);
\r
694 while ( ++index < size);
\r
699 JsonParameters param;
\r
701 cJSON *itemAllOf = cJSON_GetObjectItem(childProperties, "allOf");
\r
704 readAllOf(itemAllOf , param);
\r
706 cJSON *itemReference = cJSON_GetObjectItem(childProperties, "$ref");
\r
709 readJsonRef(itemReference , param);
\r
712 if (param.getType() == "object")
\r
714 std::vector<Properties> propertyVector;
\r
715 for (auto prop : param.getProperties())
\r
717 propertyVector.push_back(*(prop.second));
\r
719 property->setValue(propertyVector);
\r
721 for (auto req : param.getRequired())
\r
723 property->setRequiredValue(req);
\r
729 void JsonSchema::readFile(std::string &fileName , JsonParameters ¶m)
\r
731 std::string name = fileName;
\r
732 std::transform(name.begin(), name.end(), name.begin(), ::tolower);
\r
733 if (name.compare("oic.baseresource.json") == 0)
\r
736 cJSON *json = m_includeResolver->readToJson(fileName);
\r
737 JsonSchemaPtr Refparser = std::make_shared<JsonSchema>(json, m_includeResolver);
\r
739 param.addProperties(Refparser->getProperties());
\r
740 param.addRequired(Refparser->getRequiredValues());
\r
741 param.setType(Refparser->getType());
\r
744 void JsonSchema::readFile(std::string &fileName , std::string &defName , JsonParameters ¶m)
\r
746 std::string name = fileName;
\r
747 std::transform(name.begin(), name.end(), name.begin(), ::tolower);
\r
748 if (name.compare("oic.baseresource.json") == 0)
\r
751 cJSON *json = m_includeResolver->readToJson(fileName);
\r
752 JsonSchemaPtr Refparser = std::make_shared<JsonSchema>(json, m_includeResolver);
\r
754 DefinitionsPtr definition = Refparser->getDefinition(defName);
\r
755 if (definition == nullptr)
\r
756 throw JsonException("Definition Name Incorrect");
\r
758 param.addProperties(definition->getProperties());
\r
759 param.addRequired(definition->getRequiredValues());
\r
760 param.setType(definition->getType());
\r
763 void JsonSchema::readRef(std::string ref , JsonParameters ¶m)
\r
765 std::string delimiter1 = "#";
\r
766 std::string delimiter2 = "/";
\r
767 std::string fileName;
\r
770 std::size_t pos = std::string::npos;
\r
771 if ( (pos = ref.find(delimiter1)) != std::string::npos)
\r
773 fileName = ref.substr(0, pos);
\r
776 ref.erase(0, delimiter1 .length());
\r
777 std::string defName;
\r
781 ref.erase(0, delimiter2 .length());
\r
782 std::string keyName;
\r
783 if ( (pos = ref.find(delimiter2)) != std::string::npos)
\r
785 keyName = ref.substr(0, pos);
\r
786 ref.erase(0, pos + delimiter2.length());
\r
787 if (keyName == "definitions")
\r
789 if ( (pos = ref.find(delimiter2)) != std::string::npos)
\r
791 defName = ref.substr(0, pos);
\r
793 else if (! ref.empty())
\r
800 if (!fileName.empty())
\r
802 if (!(defName.empty()))
\r
804 readFile(fileName, defName, param);
\r
808 throw JsonException("Definition Name Empty");
\r
813 if (!(defName.empty()))
\r
815 if (getDefinition(defName) == nullptr)
\r
816 throw JsonException("Definition Name Incorrect");
\r
817 param.addProperties(getDefinition(defName)->getProperties());
\r
818 param.addRequired(getDefinition(defName)->getRequiredValues());
\r
819 param.setType(getDefinition(defName)->getType());
\r
823 throw JsonException("Definition Name Empty");
\r
829 void JsonSchema::readJsonRef(cJSON *jsonReference , JsonParameters ¶m)
\r
831 std::string ref = jsonReference->valuestring;
\r
833 std::string web = "http://";
\r
834 std::string delimiter = "#";
\r
835 std::size_t pos = ref.find(web);
\r
837 if (pos == std::string::npos) // If Web Link Is GIVEN TO READ
\r
839 pos = ref.find(delimiter);
\r
840 if ( pos == (ref.length() - 1) )
\r
842 std::string fileName = ref.substr(0, pos);
\r
843 readFile(fileName, param);
\r
847 readRef(ref, param);
\r
852 void JsonSchema::readAllOf(cJSON *allofValues , JsonParameters &allParams)
\r
854 int size = cJSON_GetArraySize(allofValues);
\r
858 JsonParameters param;
\r
860 cJSON *childAllOf = cJSON_GetArrayItem(allofValues, index);
\r
861 cJSON *jsonReference = cJSON_GetObjectItem(childAllOf, "$ref");
\r
864 readJsonRef(jsonReference, param);
\r
865 allParams.addProperties(param.getProperties());
\r
866 allParams.addRequired(param.getRequired());
\r
867 allParams.setType(param.getType());
\r
869 cJSON *jsonRequiredValues = cJSON_GetObjectItem(childAllOf, "required");
\r
870 if (jsonRequiredValues)
\r
872 int len = cJSON_GetArraySize(jsonRequiredValues);
\r
876 allParams.addRequired(cJSON_GetArrayItem(jsonRequiredValues, idx)->valuestring);
\r
878 while ( ++idx < len);
\r
881 while ( ++index < size);
\r