From 8e2786a656f4b16868efe562f26acbd13cde1fa7 Mon Sep 17 00:00:00 2001 From: David Glick Date: Thu, 21 Sep 2023 13:44:51 -0700 Subject: [PATCH] Support getting /@querystring vocabs in context (#1704) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Support getting /@querystring vocabs in context * changelog * Add test, update docs * Update docs/source/endpoints/querystring.md Co-authored-by: Steve Piercy --------- Co-authored-by: Víctor Fernández de Alba Co-authored-by: Steve Piercy Co-authored-by: Timo Stollenwerk --- docs/source/endpoints/querystring.md | 30 +- news/1704.feature | 1 + .../services/querystring/configure.zcml | 9 + src/plone/restapi/services/querystring/get.py | 2 +- .../querystring_get_contextual.req | 3 + .../querystring_get_contextual.resp | 1735 +++++++++++++++++ src/plone/restapi/tests/test_documentation.py | 5 + 7 files changed, 1767 insertions(+), 18 deletions(-) create mode 100644 news/1704.feature create mode 100644 src/plone/restapi/tests/http-examples/querystring_get_contextual.req create mode 100644 src/plone/restapi/tests/http-examples/querystring_get_contextual.resp diff --git a/docs/source/endpoints/querystring.md b/docs/source/endpoints/querystring.md index 03c6e6ef38..b376fa0625 100644 --- a/docs/source/endpoints/querystring.md +++ b/docs/source/endpoints/querystring.md @@ -1,40 +1,36 @@ --- myst: html_meta: - "description": "The @querystring endpoint returns the querystring configuration of plone.app.querystring." - "property=og:description": "The @querystring endpoint returns the querystring configuration of plone.app.querystring." + "description": "The @querystring endpoint returns metadata about available query operations." + "property=og:description": "The @querystring endpoint returns metadata about available query operations." "property=og:title": "Querystring" "keywords": "Plone, plone.restapi, REST, API, Querystring" --- # Querystring -The `@querystring` endpoint returns the `querystring` configuration of `plone.app.querystring`. +The `@querystring` endpoint returns metadata about the query operations that can be performed using the [`@querystringsearch`](querystringsearch) endpoint. -Instead of simply exposing the `querystring` related `field` and `operation` entries from the registry, it serializes them in the same way that `p.a.querystring` does in its `@@querybuilderjsonconfig` view. +The results include all of the indexes that can be queried, along with metadata about each index. +The top-level `indexes` property includes all indexes, and the top-level `sortable_indexes` property includes only the indexes that can be used to sort. -This form is structured in a more convenient way for frontends to process: +Each index result includes a list of the query operations that can be performed on that index. +The `operations` property contains the list of operations as dotted names. +The `operators` property contains additional metadata about each operation. -- *Vocabularies* will be resolved. - Their values will be inlined in the `values` property. -- *Operations* will be inlined as well. - The `operations` property will contain the list of operations as dotted names. - The `operators` property will contain the full definition of each of those operations supported by that field. -- Indexes that are flagged as *sortable* are listed in a dedicated top-level property `sortable_indexes`. +If an index uses a vocabulary, the vocabulary values are included in the `values` property. +The vocabulary is resolved in the same context where the `/@querystring` endpoint is called (requires `plone.app.querystring >= 2.1.0`). -Available options for the querystring in a Plone site can be queried by interacting with the `/@querystring` endpoint on the portal root: +## Get `querystring` configuration - -## Querystring Config - -To retrieve all `querystring` options in the portal, call the `/@querystring` endpoint with a `GET` request: +To get the metadata about all query operations available in the portal, call the `/@querystring` endpoint with a `GET` request: ```{eval-rst} .. http:example:: curl httpie python-requests :request: ../../../src/plone/restapi/tests/http-examples/querystring_get.req ``` -The server will respond with all `querystring` options in the portal: +The server will respond with the metadata: ```{literalinclude} ../../../src/plone/restapi/tests/http-examples/querystring_get.resp :language: http diff --git a/news/1704.feature b/news/1704.feature new file mode 100644 index 0000000000..e6f9ca41cd --- /dev/null +++ b/news/1704.feature @@ -0,0 +1 @@ +Add support for getting the `/@querystring` endpoint in a specific context. @davisagli diff --git a/src/plone/restapi/services/querystring/configure.zcml b/src/plone/restapi/services/querystring/configure.zcml index 0cc223e650..f7e6f38343 100644 --- a/src/plone/restapi/services/querystring/configure.zcml +++ b/src/plone/restapi/services/querystring/configure.zcml @@ -12,6 +12,15 @@ permission="zope2.View" name="@querystring" /> + + +