+struct json_object *afb_api_so_v1_make_description_openAPIv3(struct afb_binding_v1 *binding, const char *apiname)
+{
+ char buffer[256];
+ const struct afb_verb_desc_v1 *verb;
+ struct json_object *r, *f, *a, *i, *p, *g;
+
+ r = json_object_new_object();
+ json_object_object_add(r, "openapi", json_object_new_string("3.0.0"));
+
+ i = json_object_new_object();
+ json_object_object_add(r, "info", i);
+ json_object_object_add(i, "title", json_object_new_string(apiname));
+ json_object_object_add(i, "version", json_object_new_string("0.0.0"));
+ json_object_object_add(i, "description", json_object_new_string(binding->v1.info ?: apiname));
+
+ p = json_object_new_object();
+ json_object_object_add(r, "paths", p);
+ verb = binding->v1.verbs;
+ while (verb->name) {
+ buffer[0] = '/';
+ strncpy(buffer + 1, verb->name, sizeof buffer - 1);
+ buffer[sizeof buffer - 1] = 0;
+ f = json_object_new_object();
+ json_object_object_add(p, buffer, f);
+ g = json_object_new_object();
+ json_object_object_add(f, "get", g);
+
+ a = NULL;
+ if (verb->session & AFB_SESSION_CLOSE_X1)
+ a = addperm_key_valstr(a, "session", "close");
+ if (verb->session & AFB_SESSION_CHECK_X1)
+ a = addperm_key_valstr(a, "session", "check");
+ if (verb->session & AFB_SESSION_RENEW_X1)
+ a = addperm_key_valstr(a, "token", "refresh");
+ if (verb->session & AFB_SESSION_LOA_MASK_X1)
+ a = addperm_key_valint(a, "LOA", (verb->session >> AFB_SESSION_LOA_SHIFT_X1) & AFB_SESSION_LOA_MASK_X1);
+ if (a)
+ json_object_object_add(g, "x-permissions", a);
+
+ a = json_object_new_object();
+ json_object_object_add(g, "responses", a);
+ f = json_object_new_object();
+ json_object_object_add(a, "200", f);
+ json_object_object_add(f, "description", json_object_new_string(verb->info));
+ verb++;
+ }
+ return r;
+}