From 7402ffc941e2ffc375d96cb7e94cd7a3780a33b7 Mon Sep 17 00:00:00 2001 From: DEEPAK RAJAMOHAN Date: Tue, 11 Feb 2020 11:58:22 +0530 Subject: [PATCH] docs: update decorator documentation for url-encoded query params issue: https://github.com/strongloop/loopback-next/issues/2208 --- docs/site/decorators/Decorators_openapi.md | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/site/decorators/Decorators_openapi.md b/docs/site/decorators/Decorators_openapi.md index e6971c743be5..9caef724621b 100644 --- a/docs/site/decorators/Decorators_openapi.md +++ b/docs/site/decorators/Decorators_openapi.md @@ -191,6 +191,33 @@ You can find specific use cases in _The parameter location cookie is not supported yet, see_ _(https://github.com/strongloop/loopback-next/issues/997)_ +### Parameter decorator for objects + +One of the parameter decorator types, `@param.query.object` is applied to +generate an OpenAPI definition for query parameters with JSON values. + +The generated definition supports the `url-encoded` style specified in Open API. +This style supports receiving url-encoded payload for json query parameters. + +To filter results from the GET '/todo-list' endpoint in the +todo-list example with a specific relation, { "include": [ { "relation": "todo" +} ] }, the following url-encoded query parameter can be used, + +``` + http://localhost:3000/todos?filter=%7B%22include%22%3A%5B%7B%22relation%22%3A%22todoList%22%7D%5D%7D +``` + +As an extension to the url-encoded style, LoopBack also supports queries with +exploded values for json query parameters. + +``` +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. + ### RequestBody Decorator Syntax: see