aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-09-11 16:23:32 +0200
committerneodarz <neodarz@neodarz.net>2019-09-11 16:23:32 +0200
commita4f2b4808e79cf333d2ec2c7c72c1ac8f807c27b (patch)
tree936391347698f6c7035e881d5c50961b8e268249
parenta826aeae4b7f9a1e3b0e0d9622fe2a2f94f1d641 (diff)
downloadumosapicpp-a4f2b4808e79cf333d2ec2c7c72c1ac8f807c27b.tar.xz
umosapicpp-a4f2b4808e79cf333d2ec2c7c72c1ac8f807c27b.zip
Add ability to an object in definition propertie
Diffstat (limited to '')
-rw-r--r--api/umosapi.cpp10
1 files 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);
}