@@ -80,32 +80,37 @@ async replaceTodo(
80
80
81
81
#### Object values
82
82
83
+ {% include note.html content="
84
+ LoopBack has switched the definition of json query params from the ` exploded ` ,
85
+ ` deep-object ` style to the ` url-encoded ` style definition in Open API spec.
86
+ " %}
87
+
83
88
OpenAPI specification describes several ways how to encode object values into a
84
89
string, see
85
90
[ Style Values] ( https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#style-values )
86
91
and
87
92
[ Style Examples] ( https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#style-examples ) .
88
93
89
- At the moment, LoopBack supports object values for parameters in query strings
90
- with ` style: "deepObject" ` only . Please note that this style does not preserve
91
- encoding of primitive types, numbers and booleans are always parsed as strings.
94
+ At the moment, LoopBack supports both url-encoded and exploded values for json
95
+ query parameters . Please note that this style does not preserve the encoding of
96
+ primitive types like numbers and booleans. They are always parsed as strings.
92
97
93
- For example:
98
+ To filter results from the GET ` /todo-list ` endpoint in the todo-list example
99
+ with a relation, { "include": [ { "relation": "todo" } ] }, the following
100
+ url-encoded query parameter can be used,
94
101
95
102
```
96
- GET /todos?filter[where][completed]=false
97
- // filter={where: {completed: 'false'}}
103
+ http://localhost:3000/todos?filter=%7B%22include%22%3A%5B%7B%22relation%22%3A%22todoList%22%7D%5D%7D
98
104
```
99
105
100
- As an extension to the deep-object encoding described by OpenAPI, when the
101
- parameter is specified with ` style: "deepObject" ` , we allow clients to provide
102
- the object value as a JSON-encoded string too.
106
+ As an extension to the url-encoded style, LoopBack also supports queries with
107
+ exploded values for json query parameters.
103
108
104
109
For example:
105
110
106
111
```
107
- GET /todos?filter={" where":{" completed": false}}
108
- // filter={where: {completed: false}}
112
+ GET /todos?filter[ where][ completed]= false
113
+ // filter={where: {completed: ' false' }}
109
114
```
110
115
111
116
### Validation
0 commit comments