Skip to content

Commit

Permalink
Add parameter type name field to spec (#396)
Browse files Browse the repository at this point in the history
### Public-Facing Changes
- Add optional parameter field `type`

### Description
Adds the optional field `type` to the Parameter struct for cases where
the parameter type can't be deduced from the type of the `value` field
alone.
  • Loading branch information
achim-k authored Mar 14, 2023
1 parent 3df1f23 commit bf9d82b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Informs the client about parameters. Only supported if the server declares the `
- `parameters`: array of:
- `name`: string, name of the parameter
- `value`: number | boolean | string | number[] | boolean[] | string[]
- `type`: "byte_array" | undefined. If the type is `byte_array`, `value` shall be interpreted as base64 encoded string.
- `id`: string | undefined. Only set when the [getParameters](#get-parameters) or [setParameters](#set-parameters) request's `id` field was set

#### Example
Expand All @@ -183,6 +184,7 @@ Informs the client about parameters. Only supported if the server declares the `
{ "name": "/float_param", "value": 1.2 },
{ "name": "/string_param", "value": "foo" },
{ "name": "/node/nested_ints_param", "value": [1, 2, 3] }
{ "name": "/byte_array_param", "value": "QUJDRA==", "type": "byte_array" },
],
"id": "request-123"
}
Expand Down Expand Up @@ -396,6 +398,7 @@ Set one or more parameters. Only supported if the server previously declared tha
- `parameters`: array of:
- `name`: string
- `value`: number | boolean | string | number[] | boolean[] | string[] | undefined. If the value is not set (`undefined`), the parameter shall be unset (removed).
- `type`: "byte_array" | undefined. If the type is `byte_array`, `value` shall be a base64 encoded string.
- `id`: string | undefined, arbitrary string used for identifying the corresponding server [response](#parameter-values). If this field is not set, the server may not send a response to the client.

#### Example
Expand All @@ -405,7 +408,8 @@ Set one or more parameters. Only supported if the server previously declared tha
"op": "setParameters",
"parameters": [
{ "name": "/int_param", "value": 3 },
{ "name": "/float_param", "value": 4.1 }
{ "name": "/float_param", "value": 4.1 },
{ "name": "/byte_array_param", "value": "QUJDRA==", "type": "byte_array" }
],
"id": "request-456"
}
Expand Down
1 change: 1 addition & 0 deletions typescript/ws-protocol/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export type ClientPublish = {
export type Parameter = {
name: string;
value: number | boolean | string | number[] | boolean[] | string[] | undefined;
type?: "byte_array";
};

export type ServerMessage =
Expand Down

0 comments on commit bf9d82b

Please sign in to comment.