Bug 24302 - Add a way to specify nested objects to embed in OpenAPI
Summary: Add a way to specify nested objects to embed in OpenAPI
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low new feature (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Martin Renvoize
URL:
Keywords:
Depends on: 24228
Blocks: 18731
  Show dependency treegraph
 
Reported: 2019-12-23 18:12 UTC by Tomás Cohen Arazi
Modified: 2021-06-14 21:29 UTC (History)
10 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This development introduces a way to define embeddable objects on API routes. On the path specs, they will be specified using dot notation for nested embeddings: "x-koha-embed": [ 'biblio', 'biblio.items', 'fund' ] The consumer will need to add a header to the request, specifying the things they want to embed using comma-separated values like this: x-koha-embed: 'biblio,fund' This header will be validated against the endpoint spec and an error code will be returned if the request is not appropriate.
Version(s) released in:
20.05.00


Attachments
Bug 24302: Add a way to specify nested objects to embed in OpenAPI (2.44 KB, patch)
2019-12-23 20:34 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24302: Add a way to specify nested objects to embed in OpenAPI (6.63 KB, patch)
2019-12-24 15:44 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24302: Add a way to specify nested objects to embed in OpenAPI (6.07 KB, patch)
2019-12-26 12:00 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24302: Add a way to specify nested objects to embed in OpenAPI (6.16 KB, patch)
2019-12-26 12:07 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24302: Add a way to specify nested objects to embed in OpenAPI (6.18 KB, patch)
2020-01-02 14:37 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 24302: Add a way to specify nested objects to embed in OpenAPI (6.23 KB, patch)
2020-01-07 19:24 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 24302: Add a way to specify nested objects to embed in OpenAPI (6.26 KB, patch)
2020-01-07 19:44 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2019-12-23 18:12:59 UTC
An extension needs to be added, and a helper for handling the code so a request can include (in a header) information about objects that need to be embedded. The request header needs to be validated against the spec and return accordingly.
Comment 1 Tomás Cohen Arazi 2019-12-23 20:34:06 UTC Comment hidden (obsolete)
Comment 2 Tomás Cohen Arazi 2019-12-24 15:44:33 UTC Comment hidden (obsolete)
Comment 3 Tomás Cohen Arazi 2019-12-26 12:00:50 UTC Comment hidden (obsolete)
Comment 4 Tomás Cohen Arazi 2019-12-26 12:07:26 UTC
Created attachment 96640 [details] [review]
Bug 24302: Add a way to specify nested objects to embed in OpenAPI

This patch introduces a helper for handling x-koha-embed headers on API
requests. It reads the embed definitions and adds them to the stash for
later use (either manually on the controllers, or in the objects.search
helper.

x-koha-embed needs to be defined as a list on the OpenAPI spec.

It throws an exception when invalid combinations are found.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/REST/Plugin/Query.t
=> SUCCESS: Tests pass!
3.Sign off :-D
Comment 5 Tomás Cohen Arazi 2020-01-02 14:36:58 UTC
Comment on attachment 96640 [details] [review]
Bug 24302: Add a way to specify nested objects to embed in OpenAPI

Rebased
Comment 6 Tomás Cohen Arazi 2020-01-02 14:37:25 UTC
Created attachment 96756 [details] [review]
Bug 24302: Add a way to specify nested objects to embed in OpenAPI

This patch introduces a helper for handling x-koha-embed headers on API
requests. It reads the embed definitions and adds them to the stash for
later use (either manually on the controllers, or in the objects.search
helper.

x-koha-embed needs to be defined as a list on the OpenAPI spec.

It throws an exception when invalid combinations are found.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/REST/Plugin/Query.t
=> SUCCESS: Tests pass!
3.Sign off :-D
Comment 7 Kyle M Hall 2020-01-07 19:24:56 UTC
Created attachment 96956 [details] [review]
Bug 24302: Add a way to specify nested objects to embed in OpenAPI

This patch introduces a helper for handling x-koha-embed headers on API
requests. It reads the embed definitions and adds them to the stash for
later use (either manually on the controllers, or in the objects.search
helper.

x-koha-embed needs to be defined as a list on the OpenAPI spec.

It throws an exception when invalid combinations are found.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/REST/Plugin/Query.t
=> SUCCESS: Tests pass!
3.Sign off :-D

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 8 Kyle M Hall 2020-01-07 19:44:28 UTC
Created attachment 96957 [details] [review]
Bug 24302: Add a way to specify nested objects to embed in OpenAPI

This patch introduces a helper for handling x-koha-embed headers on API
requests. It reads the embed definitions and adds them to the stash for
later use (either manually on the controllers, or in the objects.search
helper.

x-koha-embed needs to be defined as a list on the OpenAPI spec.

It throws an exception when invalid combinations are found.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/REST/Plugin/Query.t
=> SUCCESS: Tests pass!
3.Sign off :-D

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 9 Martin Renvoize 2020-01-08 15:12:04 UTC
As per bug 24228, Passing QA
Comment 10 Martin Renvoize 2020-01-08 15:12:46 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 11 Joy Nelson 2020-01-18 16:25:26 UTC
Does not apply to 19.11.x.  Tomas if you need this in 19.11.x I'll need help getting to it to apply.  Thanks!
Comment 12 Joy Nelson 2020-02-08 00:17:00 UTC
New feature not pushed to 19.11.x