Skip to content

Commit ffdb75d

Browse files
committed
Add dbus2http_openapi.yaml
1 parent af80a65 commit ffdb75d

File tree

4 files changed

+452
-6
lines changed

4 files changed

+452
-6
lines changed

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,89 @@ dbus2http dynamically discovers DBus services, object paths, and methods via DBu
1919
* cpp-httplib: Header-only C++ HTTP server/client library (included as a submodule)
2020
* nlohmann/json: JSON serialization/deserialization (header-only)
2121
* CMake 3.19+ (build system)
22+
23+
## HTTP API
24+
25+
This project exposes a small HTTP API that maps HTTP requests to DBus operations. Main endpoints (as defined in dbus2http_openapi.yaml):
26+
27+
1) GET /dbus/service
28+
- Purpose: list DBus services visible on the system bus.
29+
- Response: JSON array of service name strings.
30+
31+
2) GET /dbus/service/{service}
32+
- Purpose: list object paths for a given service.
33+
- Path parameter:
34+
- service (string): DBus service name (e.g. org.freedesktop.NetworkManager)
35+
- Response: JSON object whose keys are object path strings and values are ObjectPath objects.
36+
- ObjectPath:
37+
- interfaces: array of strings — interfaces implemented at that path
38+
- Example:
39+
{
40+
"/org/freedesktop/NetworkManager": { "interfaces": ["org.freedesktop.NetworkManager", "org.freedesktop.DBus.Introspectable"] },
41+
"/org/freedesktop/NetworkManager/Devices/0": { "interfaces": ["org.freedesktop.NetworkManager.Device"] }
42+
}
43+
44+
3) GET /dbus/interface/{interface}
45+
- Purpose: return the introspected representation of a single interface as JSON.
46+
- Path parameter:
47+
- interface (string): interface name (e.g. org.freedesktop.NetworkManager)
48+
- Response: Interface object (see schema below).
49+
50+
Interface schema (JSON shape returned by GET /dbus/interface/{interface})
51+
- name: string
52+
- methods: object — mapping from method name to Method object
53+
- signals: object — mapping from signal name to Signal object
54+
- properties: object — mapping from property name to Property object
55+
- flags: Flags (optional metadata)
56+
57+
Method
58+
- name: string
59+
- args: array of Argument — combined in/out argument list (each Argument has direction)
60+
- flags: Flags
61+
- Example method:
62+
{
63+
"name": "GetDevices",
64+
"args": [],
65+
"flags": { "method_no_reply": false, "deprecated": false }
66+
}
67+
68+
Signal
69+
- name: string
70+
- args: array of Argument
71+
- flags: Flags
72+
73+
Property
74+
- name: string
75+
- type: string — DBus type signature (e.g. "s", "i", "a{sv}")
76+
- access: string — "read", "write", or "readwrite"
77+
- flags: Flags
78+
79+
Argument
80+
- name: string
81+
- type: string — DBus type signature
82+
- direction: string — "in" or "out"
83+
84+
Flags
85+
- deprecated: boolean
86+
- method_no_reply: boolean
87+
- privileged: boolean
88+
- emits_changed_signal: one of "TRUE" | "INVALIDATES" | "CONST" | "FALSE"
89+
- c_symbol: string (optional)
90+
91+
4) POST /dbus/call/{service}/{object_path}/{interface}/{method}
92+
- Purpose: generic DBus method invocation endpoint (documented in OpenAPI).
93+
- Path parameters:
94+
- service (string): DBus service name
95+
- object_path (string): object path (leading '/'), may contain additional '/' characters
96+
- interface (string): interface name
97+
- method (string): method name
98+
- Request body: MethodCall (free-form JSON mapping argument name -> value)
99+
- Response: MethodReply (free-form JSON; if single basic value, may appear as "result")
100+
101+
MethodCall / MethodReply
102+
- MethodCall: free-form object; server adapts JSON to DBus types using introspection signatures.
103+
- MethodReply: free-form object representing the method return value(s).
104+
105+
Notes on path parsing
106+
- object_path may contain '/' characters. When constructing requests clients can URL-encode path segments.
107+
- The OpenAPI path for method invocation uses separate path parameters to avoid ambiguous captures; clients should follow the documented encoding rules.

0 commit comments

Comments
 (0)