]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
knotc: add OPTINT in JSON schema of configuration file
authorJan Hák <jan.hak@nic.cz>
Mon, 24 Nov 2025 14:11:46 +0000 (15:11 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Mon, 24 Nov 2025 14:55:09 +0000 (15:55 +0100)
src/knot/conf/base.c

index 04329bf6723b4f08176bda80a79b767926bd9e2c..5bc126d353be1005c28a5b0f3129d997f4f654d8 100644 (file)
@@ -1175,7 +1175,28 @@ static void export_type(jsonw_t *w, const yp_item_t *item)
                );
                break;
        case YP_TOPTINT:
-               // TODO
+               SINGLE_OR_ARRAY(
+                       jsonw_list(w, "anyOf");
+                       jsonw_object(w, NULL);
+                       jsonw_str(w, "$ref", "#/$defs/int");
+                       jsonw_end(w);
+                       jsonw_object(w, NULL);
+                       jsonw_str(w, "$ref", "#/$defs/int_time");
+                       jsonw_end(w);
+                       jsonw_object(w, NULL);
+                       jsonw_str(w, "$ref", "#/$defs/int_size");
+                       jsonw_end(w);
+                       jsonw_object(w, NULL);
+                       jsonw_str(w, "type", "string");
+                       jsonw_list(w, "enum");
+                       for (const knot_lookup_t *o = item->var.i.opts;
+                            o->name != NULL; ++o) {
+                               jsonw_str(w, NULL, o->name);
+                       }
+                       jsonw_end(w);
+                       jsonw_end(w);
+                       jsonw_end(w);
+               );
                break;
        default:
                assert(0);