//#define PRINT_RESOURCE_URI_BASEURI\r
//#define PRINT_ACTION_QUERY_PARAM\r
//#define PRINT_RESPONSE_HEADER\r
-//#define PRINT_REQUEST_RESPONSE_BODY_PARAMS\r
+#define PRINT_REQUEST_RESPONSE_BODY_PARAMS\r
//#define PRINT_ACTION_HEADERS\r
//#define PRINT_SCHEMAS\r
#define PRINT_RAML\r
#define PRINT_JSON\r
-//#define PRINT_JSON_PROPERTIES\r
+//#define PRINT_JSON_DEFINITION\r
+#define PRINT_JSON_PROPERTIES\r
\r
using namespace RAML;\r
\r
-void printParameters(AbstractParam abstractParam)\r
-{\r
+void printProperties(const PropertiesPtr &prop);\r
\r
#ifdef PRINT_PARAMS\r
+void printParameters(AbstractParam abstractParam)\r
+{\r
std::cout << "Description : " << abstractParam.getDescription() << std::endl;\r
std::cout << "DefaultValue : " << abstractParam.getDefaultValue() << std::endl;\r
std::cout << "Example : " << abstractParam.getExample() << std::endl;\r
for (auto elem : abstractParam.getEnumeration())\r
std::cout << elem << " ";\r
std::cout << std::endl;\r
-#endif\r
}\r
+#endif\r
\r
void printRequestResponseBody(const RequestResponseBodyPtr &body)\r
{\r
std::cout << "Body : Type : " << body->getType() << std::endl;\r
if ( body->getSchema() == NULL ) return;\r
+#ifdef PRINT_SCHEMAS\r
std::cout << "Body : Schema : " << body->getSchema()->getSchema() << std::endl;\r
+#endif\r
std::cout << "Body : Schema : PROPERTIES :" << std::endl;\r
\r
for ( auto pro : body->getSchema()->getProperties()->getProperties() )\r
{\r
- std::cout << "-----------------------------" << std::endl;\r
- std::cout << "Name : " << pro.second->getName() << std::endl;\r
- std::cout << "-----------------------------" << std::endl;\r
- try\r
- {\r
- switch (pro.second->getVariantType())\r
- {\r
- case VariantType::INT : // Integer\r
- std::cout << "Defaut: " << pro.second->getValueInt() << std::endl;\r
- for (auto tt : pro.second->getAllowedValuesInt())\r
- {\r
- std::cout << "enum value : " << tt << std::endl;\r
- }\r
- {\r
- int min = 0, max = 0, mul = 0;\r
- pro.second->getRange(min, max, mul);\r
- std::cout << "Minimum: " << min << std::endl;\r
- std::cout << "Maximum: " << max << std::endl;\r
- }\r
- break;\r
-\r
- case VariantType::DOUBLE : // Double\r
- std::cout << "Defaut: " << pro.second->getValueDouble() << std::endl;\r
- for (auto tt : pro.second->getAllowedValuesDouble())\r
- {\r
- std::cout << "enum value : " << tt << std::endl;\r
- }\r
- {\r
- double min = 0, max = 0;\r
- int mul = 0;\r
- pro.second->getRangeDouble(min, max, mul);\r
- std::cout << "MinimumDouble: " << min << std::endl;\r
- std::cout << "MaximumDouble: " << max << std::endl;\r
- }\r
- break;\r
-\r
- case VariantType::BOOL : // Boolean\r
- std::cout << "Defaut: " << std::boolalpha << pro.second->getValueBool() << std::noboolalpha <<\r
- std::endl;\r
- for (auto tt : pro.second->getAllowedValuesBool())\r
- {\r
- std::cout << "enum value : " << tt << std::endl;\r
- }\r
- break;\r
-\r
- case VariantType::STRING : // String\r
- std::cout << "Defaut: " << pro.second->getValueString() << std::endl;\r
- for (auto tt : pro.second->getAllowedValuesString())\r
- {\r
- std::cout << "enum value : " << tt << std::endl;\r
- }\r
- {\r
- int min = 0, max = 0, mul = 0;\r
- pro.second->getRange(min, max, mul);\r
- std::cout << "MinimumLength: " << min << std::endl;\r
- std::cout << "MaximumLength: " << max << std::endl;\r
- }\r
- break;\r
- default:\r
- break;\r
+ printProperties(pro.second);\r
+ }\r
\r
- }\r
- }\r
- catch (const boost::bad_lexical_cast &e)\r
- {\r
- std::cout << e.what() << std::endl;\r
- }\r
- catch ( ... )\r
+ std::cout << "Body : Schema : ITEMS :" << std::endl;\r
+ for (auto it : body->getSchema()->getProperties()->getItems())\r
+ {\r
+ for (auto tt : it->getProperties())\r
{\r
- std::cout << "Unknown exception caught!" << std::endl;\r
+ printProperties(tt.second);\r
}\r
-\r
}\r
+#ifdef PRINT_SCHEMAS\r
std::cout << "-----------------------------" << std::endl;\r
std::cout << "Body : example : " << body->getExample() << std::endl;\r
+#endif\r
\r
#ifdef PRINT_REQUEST_RESPONSE_BODY_PARAMS\r
std::cout << "Body : FormParameters " << std::endl;\r
std::cout << tw.first << " : " << std::endl;\r
std::cout << "-----------------------------" << std::endl;\r
FormParameter formParameter = *tw.second;\r
+#ifdef PRINT_PARAMS\r
printParameters((AbstractParam)formParameter);\r
+#endif\r
}\r
#endif\r
}\r
std::cout << "-----------------------------" << std::endl;\r
\r
Header header = *tw.second;\r
+#ifdef PRINT_PARAMS\r
printParameters((AbstractParam)header);\r
+#endif\r
}\r
#endif\r
}\r
std::cout << tw.first << " : " << std::endl;\r
std::cout << "-----------------------------" << std::endl;\r
QueryParameter queryParam = *tw.second;\r
+#ifdef PRINT_PARAMS\r
printParameters((AbstractParam)queryParam);\r
+#endif\r
}\r
#endif\r
#ifdef PRINT_ACTION_HEADERS\r
std::cout << tw.first << " : " << std::endl;\r
std::cout << "-----------------------------" << std::endl;\r
Header header = *tw.second;\r
+#ifdef PRINT_PARAMS\r
printParameters((AbstractParam)header);\r
+#endif\r
}\r
#endif\r
\r
std::cout << tt.first << " : " << std::endl;\r
std::cout << "-----------------------------" << std::endl;\r
UriParameter uriParameter = *tt.second;\r
+#ifdef PRINT_PARAMS\r
printParameters((AbstractParam)uriParameter);\r
+#endif\r
}\r
std::cout << "#############################################" << std::endl;\r
std::cout << "BaseUriParameters " << std::endl;\r
std::cout << "-----------------------------" << std::endl;\r
\r
UriParameter uriParameter = *tt.second;\r
+#ifdef PRINT_PARAMS\r
printParameters((AbstractParam)uriParameter);\r
+#endif\r
}\r
#endif\r
std::cout << "Actions " << std::endl;\r
std::cout << "enum value : " << tt << std::endl;\r
}\r
{\r
- int min = 0, max = 0, mul = 0;\r
+ double min = 0, max = 0;\r
+ int mul = 0;\r
prop->getRange(min, max, mul);\r
std::cout << "Minimum: " << min << std::endl;\r
std::cout << "Maximum: " << max << std::endl;\r
{\r
double min = 0, max = 0;\r
int mul = 0;\r
- prop->getRangeDouble(min, max, mul);\r
+ prop->getRange(min, max, mul);\r
std::cout << "MinimumDouble: " << min << std::endl;\r
std::cout << "MaximumDouble: " << max << std::endl;\r
}\r
std::cout << "enum value : " << tt << std::endl;\r
}\r
{\r
- int min = 0, max = 0, mul = 0;\r
+ double min = 0, max = 0;\r
+ int mul = 0;\r
prop->getRange(min, max, mul);\r
std::cout << "MinimumLength: " << min << std::endl;\r
std::cout << "MaximumLength: " << max << std::endl;\r
std::cout << "Type: " << js->getType() << std::endl;\r
std::cout << "Description: " << js->getDescription() << std::endl;\r
std::cout << "AdditionalProperties: " << js->getAdditionalProperties() << std::endl;\r
-\r
+#ifdef PRINT_JSON_DEFINITION\r
std::cout << "-------------------------------" << std::endl;\r
std::cout << "Definitions." << std::endl;\r
for (auto tt : js->getDefinitions())\r
printProperties(it.second);\r
}\r
}\r
-\r
+#endif\r
std::cout << "##############################" << std::endl;\r
std::cout << "Properties." << std::endl;\r
for (auto it : js->getProperties())\r
std::cout << it << std::endl;\r
}\r
std::cout << "-------------------------------" << std::endl;\r
+ std::cout << "Items." << std::endl;\r
+ std::cout << "-------------------------------" << std::endl;\r
+ for (auto it : js->getItems())\r
+ {\r
+ for (auto tt : it->getProperties())\r
+ {\r
+ printProperties(tt.second);\r
+ }\r
+ std::cout << "-------------------------------" << std::endl;\r
+ std::cout << "Required." << std::endl;\r
+ std::cout << "-------------------------------" << std::endl;\r
+ for (auto tt : it->getRequiredValues())\r
+ {\r
+ std::cout << tt << std::endl;\r
+ }\r
+ }\r
+ std::cout << "-------------------------------" << std::endl;\r
}\r
\r
int main(int argc, char *argv[])\r
std::cout << it.first << " : " << std::endl;\r
std::cout << "-----------------------------" << std::endl;\r
UriParameter uriParameter = *it.second;\r
+#ifdef PRINT_PARAMS\r
printParameters((AbstractParam)uriParameter);\r
+#endif\r
}\r
#endif\r
#ifdef PRINT_SCHEMAS\r
{\r
return;\r
}\r
- for (auto const & it : resource)\r
+ for (auto const &it : resource)\r
{\r
std::string type = getRamlPtr()->getMediaType();\r
\r
- for (auto const & action : it.second->getActions())\r
+ for (auto const &action : it.second->getActions())\r
{\r
if (action.second->getRequestBody().empty())\r
{\r
action.second->setRequestBody(type);\r
}\r
- for (auto const & response : action.second->getResponses())\r
+ for (auto const &response : action.second->getResponses())\r
{\r
if (response.second->getResponseBody().empty())\r
{\r
{\r
return;\r
}\r
- for (auto const & it : resource)\r
+ for (auto const &it : resource)\r
{\r
- for (auto const & action : it.second->getActions())\r
+ for (auto const &action : it.second->getActions())\r
{\r
- for (auto const & body : action.second->getRequestBody())\r
+ for (auto const &body : action.second->getRequestBody())\r
{\r
SchemaPtr schema = body.second->getSchema();\r
\r
}\r
}\r
}\r
- for (auto const & response : action.second->getResponses())\r
+ for (auto const &response : action.second->getResponses())\r
{\r
- for (auto const & body : response.second->getResponseBody())\r
+ for (auto const &body : response.second->getResponseBody())\r
{\r
SchemaPtr schema = body.second->getSchema();\r
if (schema != NULL)\r
{\r
return;\r
}\r
- for (auto const & it : resource)\r
+ for (auto const &it : resource)\r
{\r
auto const &resourceTypes = getRamlPtr()->getResourceTypes();\r
std::string typeValue = it.second->getResourceType();\r
{\r
return;\r
}\r
- for (auto const & it : resource)\r
+ for (auto const &it : resource)\r
{\r
auto const &trait = getRamlPtr()->getTraits();\r
- for (auto const & act : it.second->getActions())\r
+ for (auto const &act : it.second->getActions())\r
{\r
- for (const std::string & traitValue : act.second->getTraits())\r
+ for (const std::string &traitValue : act.second->getTraits())\r
{\r
auto iter = trait.begin();\r
for (; iter != trait.end(); iter++)\r
}\r
}\r
}\r
- for (const std::string & traitValue : it.second->getTraits())\r
+ for (const std::string &traitValue : it.second->getTraits())\r
{\r
auto iter = trait.begin();\r
for (; iter != trait.end(); iter++)\r
/**\r
* Constructor of Properties.\r
*/\r
- Properties(): m_min(INT_MAX), m_max(INT_MAX), m_doubleMin(INT_MAX), m_doubleMax(INT_MAX),\r
+ Properties(): m_min(INT_MAX), m_max(INT_MAX),\r
m_multipleOf(INT_MAX), m_unique(false), m_additionalItems(false) {}\r
\r
/**\r
* @param name - Properties name as string.\r
*/\r
Properties(const std::string &name) : m_name(name), m_min(INT_MAX), m_max(INT_MAX),\r
- m_doubleMin(INT_MAX), m_doubleMax(INT_MAX), m_multipleOf(INT_MAX),\r
+ m_multipleOf(INT_MAX),\r
m_unique(false), m_additionalItems(false) {}\r
\r
/**\r
* @param max - reference to hold Maximum value of Properties.\r
* @param multipleOf - reference to hold multipleOf value of Properties.\r
*/\r
- inline void getRange(int &min, int &max, int &multipleOf) const\r
+ inline void getRange(double &min, double &max, int &multipleOf) const\r
{\r
min = m_min;\r
max = m_max;\r
}\r
\r
/**\r
- * This method is for getting Range from Properties.\r
- *\r
- * @param min - reference to hold Minimum value of Properties.\r
- * @param max - reference to hold Maximum value of Properties.\r
- * @param multipleOf - reference to hold multipleOf value of Properties.\r
- */\r
- inline void getRangeDouble(double &min, double &max, int &multipleOf) const\r
- {\r
- min = m_doubleMin;\r
- max = m_doubleMax;\r
- multipleOf = m_multipleOf;\r
- }\r
- /**\r
- * This method is for setting Minimum to Properties\r
+ * This method is for setting Minimum to Properties.\r
*\r
* @param min - Minimum value of Properties.\r
*/\r
- inline void setMin(const int &min)\r
+ inline void setMin(const double &min)\r
{\r
m_min = min;\r
}\r
*\r
* @param max - Maximum value of Properties.\r
*/\r
- inline void setMax(const int &max)\r
+ inline void setMax(const double &max)\r
{\r
m_max = max;\r
}\r
-\r
- /**\r
- * This method is for setting Minimum to Properties\r
- *\r
- * @param min - Minimum value of Properties.\r
- */\r
- inline void setMinDouble(const double &min)\r
- {\r
- m_doubleMin = min;\r
- }\r
-\r
- /**\r
- * This method is for setting Maximum to Properties\r
- *\r
- * @param max - Maximum value of Properties.\r
- */\r
- inline void setMaxDouble(const double &max)\r
- {\r
- m_doubleMax = max;\r
- }\r
/**\r
* This method is for setting multipleOf to Properties\r
*\r
private:\r
std::string m_name;\r
ValueVariant m_value;\r
- int m_min;\r
- int m_max;\r
- double m_doubleMin;\r
- double m_doubleMax;\r
+ double m_min;\r
+ double m_max;\r
int m_multipleOf;\r
AllowedValues m_allowedValues;\r
std::string m_type;\r