From f0048bc73b2bb38e017145ef84d46a608635662c Mon Sep 17 00:00:00 2001 From: DEEPAK RAJAMOHAN Date: Tue, 11 Feb 2020 11:28:30 +0530 Subject: [PATCH] docs: update docs for issue 2208 switching to url-encoded style params https://github.com/strongloop/loopback-next/issues/2208 --- docs/site/Parsing-requests.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/site/Parsing-requests.md b/docs/site/Parsing-requests.md index f70cae304bbc..20ac8d6e20c7 100644 --- a/docs/site/Parsing-requests.md +++ b/docs/site/Parsing-requests.md @@ -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 encoding of +primitive types, numbers and booleans are always parsed as strings. -For example: +For instance, to filter api 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 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