Skip to content

Commit d29c3cb

Browse files
committed
Draft of HTTP protocol mapping
1 parent 1279db2 commit d29c3cb

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

cddl/http-protocol-map.cddl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$$SDF-EXTENSION-DATA //= http-protocol-map
2+
3+
http-protocol-map = {
4+
method: "GET" / "POST" / "PUT" / "DELETE"
5+
path: text
6+
? query: {text => text}
7+
? headers: {text => text}
8+
? body: text
9+
}

draft-mohan-asdf-sdf-protocol-mapping.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,46 @@ For example, a Zigbee protocol mapping for a temperature property might look lik
326326
The protocol mapping mechanism can also be used for IP-based protocols
327327
such as HTTP or CoAP.
328328

329+
### HTTP
330+
331+
The HTTP protocol mapping allows SDF models to specify how properties, actions,
332+
and events should be accessed using the HTTP protocol. The mapping includes
333+
details such as method, path, optional headers, request body and query
334+
parameters that are used to access the corresponding SDF affordances.
335+
336+
~~~ cddl
337+
{::include cddl/http-protocol-map.cddl}
338+
~~~
339+
{: #httpmap1 title="CDDL definition for HTTP OpenAPI Protocol Mapping for properties, actions, and events"}
340+
341+
Where:
342+
343+
- `method` is the method of the HTTP request towards the affordance. Allowed methods are `GET`, `POST`, `PUT`, and `DELETE`.
344+
- `path` is the path targeted by the HTTP request.
345+
- `query` is the optional query string expressed as a text map. The key of the map is the name of the query parameter and the value of the map is the value of the query parameter.
346+
- `headers` is the optional set of HTTP headers expressed as text map. The key of the map is the name of the header and the value of the map is the value of the header field.
347+
- `body` is the optional body of the HTTP request expressed as text.
348+
349+
For example, a HTTP protocol mapping for a temperature property might look like:
350+
351+
~~~ jsonc
352+
{
353+
"sdfProperty": {
354+
"temperature": {
355+
"sdfProtocolMap": {
356+
"http": {
357+
"method": "GET",
358+
"path": "/device/123/temperature/0",
359+
"query": {"unit": "celsius"},
360+
}
361+
}
362+
}
363+
}
364+
}
365+
~~~
366+
367+
The above SDF Protocol Mapping will be resolved to the following HTTP request: `GET /device/123/temperature/0?unit=celsius`.
368+
329369
### OpenAPI Protocol Mapping Structure
330370

331371
In the case of HTTP, SDF protocol mappings towards an SDF quality MAY be

0 commit comments

Comments
 (0)