Skip to content

Commit

Permalink
docs: update docs for issue 2208 switching to url-encoded style params
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakrkris committed Feb 12, 2020
1 parent 2e66aab commit 0bfaaff
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions docs/site/Parsing-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,32 @@ string, see
and
[Style Examples](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#style-examples).

At the moment, LoopBack supports object values for parameters in query strings
with `style: "deepObject"` only. Please note that this style does not preserve
encoding of primitive types, numbers and booleans are always parsed as strings.
At the moment, LoopBack supports both url-encoded and exploded values for json
query parameters. Please note that this style does not preserve the encoding of
primitive types like numbers and booleans. They are always parsed as strings.

For example:
To filter results from the GET '/todo-list' endpoint in the
todo-list example with a relation, { "include": [ { "relation": "todo" } ] },
the following url-encoded query parameter can be used,

```
GET /todos?filter[where][completed]=false
// filter={where: {completed: 'false'}}
http://localhost:3000/todos?filter=%7B%22include%22%3A%5B%7B%22relation%22%3A%22todoList%22%7D%5D%7D
```

As an extension to the deep-object encoding described by OpenAPI, when the
parameter is specified with `style: "deepObject"`, we allow clients to provide
the object value as a JSON-encoded string too.
As an extension to the url-encoded style, LoopBack also supports queries with
exploded values for json query parameters.

For example:

```
GET /todos?filter={"where":{"completed":false}}
// filter={where: {completed: false}}
GET /todos?filter[where][completed]=false
// filter={where: {completed: 'false'}}
```

LoopBack has switched the definition of json query params from the `exploded`,
`deep-object` style to the `url-encoded` style definition in Open-API spec, in a
recent release.

### Validation

Validations are applied on the parameters and the request body data. They also
Expand Down

0 comments on commit 0bfaaff

Please sign in to comment.