-
- verb = search(desc, name);
- if (!verb)
- afb_req_fail_f(req, "unknown-verb", "verb %s unknown within api %s", name, desc->binding->api);
- else if (call_check(req, context, verb)) {
- afb_thread_req_call(req, verb->callback, afb_api_so_timeout, desc);
+ 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(desc->binding->api));
+ json_object_object_add(i, "version", json_object_new_string("0.0.0"));
+ json_object_object_add(i, "description", json_object_new_string(desc->binding->info ?: desc->binding->api));
+
+ p = json_object_new_object();
+ json_object_object_add(r, "paths", p);
+ verb = desc->binding->verbs;
+ while (verb->verb) {
+ buffer[0] = '/';
+ strncpy(buffer + 1, verb->verb, 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_V2)
+ a = addperm_key_valstr(a, "session", "close");
+ if (verb->session & AFB_SESSION_CHECK_V2)
+ a = addperm_key_valstr(a, "session", "check");
+ if (verb->session & AFB_SESSION_REFRESH_V2)
+ a = addperm_key_valstr(a, "token", "refresh");
+ if (verb->session & AFB_SESSION_LOA_MASK_V2)
+ a = addperm_key_valint(a, "LOA", verb->session & AFB_SESSION_LOA_MASK_V2);
+#if 0
+ if (verb->auth)
+ a =
+#endif
+ 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->verb));
+ verb++;