aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-09-11 16:53:56 +0200
committerneodarz <neodarz@neodarz.net>2019-09-11 17:07:28 +0200
commitcafab1abb5912100b2e1ddccb753ccb5d7c9972f (patch)
tree56951242f9e6806c0c75c85cadc168b05eb1effa /api
parent856e37f89bf103b1d78f4f8a38a10fb3f42ed4b4 (diff)
downloadumosapicpp-cafab1abb5912100b2e1ddccb753ccb5d7c9972f.tar.xz
umosapicpp-cafab1abb5912100b2e1ddccb753ccb5d7c9972f.zip
Add ability to don't set definition for a response
Diffstat (limited to 'api')
-rw-r--r--api/umosapi.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/api/umosapi.cpp b/api/umosapi.cpp
index 6343f20..ee2705d 100644
--- a/api/umosapi.cpp
+++ b/api/umosapi.cpp
@@ -219,15 +219,19 @@ void UmosapiService::Api::parameter(std::string name, std::string description, s
UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["parameters"].push_back(parameter);
}
-void UmosapiService::Api::response(std::string http_code, std::string description, std::string definition, std::string type = "object") {
+void UmosapiService::Api::response(std::string http_code, std::string description, std::string definition = "", std::string type = "object") {
std::string schema = "#/definitions/";
- if (type == "object") {
- UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["responses"][http_code]["description"] = description;
- UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["responses"][http_code]["schema"]["$ref"] = schema.append(definition);
+ if (definition != "") {
+ if (type == "object") {
+ UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["responses"][http_code]["description"] = description;
+ UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["responses"][http_code]["schema"]["$ref"] = schema.append(definition);
+ } else {
+ UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["responses"][http_code]["description"] = description;
+ UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["responses"][http_code]["schema"]["items"]["$ref"] = schema.append(definition);
+ UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["responses"][http_code]["schema"]["type"] = type;
+ }
} else {
UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["responses"][http_code]["description"] = description;
- UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["responses"][http_code]["schema"]["items"]["$ref"] = schema.append(definition);
- UmosapiService::Api::_swagger["paths"][UmosapiService::Api::_path.name][UmosapiService::Api::_path.words.back().name]["responses"][http_code]["schema"]["type"] = type;
}
}