From 12681e4121c56e7f7aeb3d6dfd6e69cdb103ccef Mon Sep 17 00:00:00 2001 From: Alexey Efimov Date: Fri, 31 May 2024 05:48:48 +0000 Subject: [PATCH] fix swagger schema --- ydb/core/viewer/json_nodelist.h | 4 ---- ydb/core/viewer/json_pdisk_restart.h | 22 +++++++++++----------- ydb/core/viewer/viewer.cpp | 3 +-- ydb/core/viewer/yaml/yaml.cpp | 2 +- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/ydb/core/viewer/json_nodelist.h b/ydb/core/viewer/json_nodelist.h index 77a14fe3d035..d1d3310f616e 100644 --- a/ydb/core/viewer/json_nodelist.h +++ b/ydb/core/viewer/json_nodelist.h @@ -101,10 +101,6 @@ struct TJsonRequestSchema { type: string Port: type: integer - required: - - Id - - Address - - Port )___"); } }; diff --git a/ydb/core/viewer/json_pdisk_restart.h b/ydb/core/viewer/json_pdisk_restart.h index 49e6e373ef2d..489be7402730 100644 --- a/ydb/core/viewer/json_pdisk_restart.h +++ b/ydb/core/viewer/json_pdisk_restart.h @@ -177,8 +177,6 @@ YAML::Node TJsonRequestSwagger::GetSwagger() { post: tags: - pdisk - produces: - - application/json summary: Restart PDisk description: Restart PDisk on the specified node parameters: @@ -210,15 +208,17 @@ YAML::Node TJsonRequestSwagger::GetSwagger() { responses: 200: description: OK - schema: - type: object - properties: - result: - type: boolean - description: was operation successful or not - error: - type: string - description: details about failed operation + content: + application/json: + schema: + type: object + properties: + result: + type: boolean + description: was operation successful or not + error: + type: string + description: details about failed operation 400: description: Bad Request 403: diff --git a/ydb/core/viewer/viewer.cpp b/ydb/core/viewer/viewer.cpp index 9f7ee3984719..cf64d64facbd 100644 --- a/ydb/core/viewer/viewer.cpp +++ b/ydb/core/viewer/viewer.cpp @@ -253,7 +253,6 @@ class TViewer : public TActorBootstrapped, public IViewer { if (swagger.IsNull()) { auto get = path["get"]; get["tags"].push_back(tag); - get["produces"].push_back("application/json"); if (auto summary = handler->GetRequestSummary()) { get["summary"] = summary; } @@ -263,7 +262,7 @@ class TViewer : public TActorBootstrapped, public IViewer { get["parameters"] = handler->GetRequestParameters(); auto responses = get["responses"]; auto response200 = responses["200"]; - response200["schema"] = handler->GetResponseJsonSchema(); + response200["content"]["application/json"]["schema"] = handler->GetResponseJsonSchema(); } else { path = swagger; } diff --git a/ydb/core/viewer/yaml/yaml.cpp b/ydb/core/viewer/yaml/yaml.cpp index 34e6b5af6dbc..c99e35423dc2 100644 --- a/ydb/core/viewer/yaml/yaml.cpp +++ b/ydb/core/viewer/yaml/yaml.cpp @@ -31,7 +31,7 @@ YAML::Node TProtoToYaml::ProtoToYamlSchema(const ::google::protobuf::Descriptor* auto property = properties[fieldDescriptor->name()]; if (fieldDescriptor->is_repeated()) { property["type"] = "array"; - property = property["items"]; + property.reset(property["items"]); } if (fieldDescriptor->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { if (fieldDescriptor->message_type()->full_name() == google::protobuf::Timestamp::descriptor()->full_name()) {