martinzink commented on code in PR #1926:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1926#discussion_r2001001935


##########
libminifi/src/agent/JsonSchema.cpp:
##########
@@ -61,35 +62,37 @@ void writePropertySchema(const core::Property& prop, 
std::ostream& out) {
   if (const auto& values = prop.getAllowedValues(); !values.empty()) {
     out << R"(, "enum": [)"
         << (values
-            | ranges::views::transform([] (auto& val) {return '"' + 
escape(val.to_string()) + '"';})
+            | ranges::views::transform([] (auto& val) {return '"' + 
escape(val) + '"';})
             | ranges::views::join(',')
             | ranges::to<std::string>())
         << "]";
   }
-  if (const auto& def_value = prop.getDefaultValue(); !def_value.empty()) {
-    const auto& type = def_value.getTypeInfo();
-    // order is important as both DataSizeValue and TimePeriodValue's type_id 
is uint64_t
-    if (std::dynamic_pointer_cast<core::DataSizeValue>(def_value.getValue())
-        || 
std::dynamic_pointer_cast<core::TimePeriodValue>(def_value.getValue())) {  // 
NOLINT(bugprone-branch-clone)
-      // special value types
-      out << R"(, "type": "string", "default": ")" << 
escape(def_value.to_string()) << "\"";
-    } else if (type == state::response::Value::INT_TYPE
-        || type == state::response::Value::INT64_TYPE
-        || type == state::response::Value::UINT32_TYPE
-        || type == state::response::Value::UINT64_TYPE) {
-      out << R"(, "type": "integer", "default": )" << 
static_cast<int64_t>(def_value);
-    } else if (type == state::response::Value::DOUBLE_TYPE) {
-      out << R"(, "type": "number", "default": )" << 
static_cast<double>(def_value);
-    } else if (type == state::response::Value::BOOL_TYPE) {
-      out << R"(, "type": "boolean", "default": )" << 
(static_cast<bool>(def_value) ? "true" : "false");
+  if (const auto validator_name = 
prop.getValidator().getEquivalentNifiStandardValidatorName()) {
+    if (validator_name == "INTEGER_VALIDATOR" || validator_name == 
"NON_NEGATIVE_INTEGER_VALIDATOR") {

Review Comment:
   good idea, 
https://github.com/apache/nifi-minifi-cpp/commit/fca64f30d1f155ec304403f6e5bcbf4b8341cf6e



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to