Bug 24302

Summary: Add a way to specify nested objects to embed in OpenAPI
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: REST APIAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: new feature    
Priority: P5 - low CC: 1joynelson, agustinmoyano, ere.maijala, jonathan.druart, josef.moravec, kyle, martin.renvoize, nick, oleonard, tomascohen
Version: Main   
Hardware: All   
OS: All   
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
Bug Depends on: 24228    
Bug Blocks: 18731    
Attachments: Bug 24302: Add a way to specify nested objects to embed in OpenAPI
Bug 24302: Add a way to specify nested objects to embed in OpenAPI
Bug 24302: Add a way to specify nested objects to embed in OpenAPI
Bug 24302: Add a way to specify nested objects to embed in OpenAPI
Bug 24302: Add a way to specify nested objects to embed in OpenAPI
Bug 24302: Add a way to specify nested objects to embed in OpenAPI
Bug 24302: Add a way to specify nested objects to embed in OpenAPI

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