- /* get the event handler if any */
- onevent = desc->binding->onevent;
- desc->service = afb_svc_create_v2(apiset, share_session, start, onevent, &desc->ditf);
- if (desc->service == NULL) {
- /* starting error */
- ERROR("Starting service %s failed", desc->binding->api);
- return -1;
+ 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->info ?: apiname));
+
+ p = json_object_new_object();
+ json_object_object_add(r, "paths", p);
+ verb = 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 = afb_auth_json_v2(verb->auth, verb->session);
+ 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++;