From a4f2b4808e79cf333d2ec2c7c72c1ac8f807c27b Mon Sep 17 00:00:00 2001 From: neodarz Date: Wed, 11 Sep 2019 16:23:32 +0200 Subject: Add ability to an object in definition propertie --- api/umosapi.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/umosapi.cpp b/api/umosapi.cpp index c14e9a5..bd58f8a 100644 --- a/api/umosapi.cpp +++ b/api/umosapi.cpp @@ -175,8 +175,14 @@ void UmosapiService::Api::definition(std::string name, std::string type) { void UmosapiService::Api::propertie(std::string name, std::string format, std::string type, std::string required) { UmosapiService::Api::_definition.props.push_back(Propertie{name, format, type, required}); - UmosapiService::Api::_swagger["definitions"][UmosapiService::Api::_definition.name]["properties"][name]["format"] = format; - UmosapiService::Api::_swagger["definitions"][UmosapiService::Api::_definition.name]["properties"][name]["type"] = type; + if (type == "ref") { + UmosapiService::Api::_swagger["definitions"][UmosapiService::Api::_definition.name]["type"] = "array"; + std::string schema_path = "#/definitions/"; + UmosapiService::Api::_swagger["definitions"][UmosapiService::Api::_definition.name]["items"]["$ref"] = schema_path.append(name); + } else { + UmosapiService::Api::_swagger["definitions"][UmosapiService::Api::_definition.name]["properties"][name]["format"] = format; + UmosapiService::Api::_swagger["definitions"][UmosapiService::Api::_definition.name]["properties"][name]["type"] = type; + } if (required == "true") { UmosapiService::Api::_swagger["definitions"][UmosapiService::Api::_definition.name]["required"].push_back(name); } -- cgit v1.2.1