Bug 21334 - Add bibliographic content type definitions
Summary: Add bibliographic content type definitions
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Josef Moravec
URL:
Keywords:
Depends on:
Blocks: 17371
  Show dependency treegraph
 
Reported: 2018-09-11 17:31 UTC by Tomás Cohen Arazi
Modified: 2020-01-06 20:14 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 21334: Unit tests (2.13 KB, patch)
2018-09-11 18:25 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 21334: Add bibliographic content type definitions (1.85 KB, patch)
2018-09-11 18:25 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 21334: Add bibliographic content type definitions (1.87 KB, patch)
2018-09-11 18:38 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 21334: Add bibliographic content type definitions (1.91 KB, patch)
2018-09-12 12:39 UTC, Michal Denar
Details | Diff | Splinter Review
Bug 21334: Unit tests (2.24 KB, patch)
2018-09-12 18:37 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 21334: Add bibliographic content type definitions (1.96 KB, patch)
2018-09-12 18:37 UTC, Josef Moravec
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 2018-09-11 17:31:31 UTC
Biblio and authority records need some content-type definitions to be added to the Mojolicious startup code:

- 'application/marcxml+xml'
- 'application/marc-in-json'
- 'application/marc'
Comment 1 Tomás Cohen Arazi 2018-09-11 18:25:15 UTC
Created attachment 78563 [details] [review]
Bug 21334: Unit tests

This patch adds unit tests for the new content types being added.
It also adds tests for the 'json' overloading that already takes place
in V1.pm.
Comment 2 Tomás Cohen Arazi 2018-09-11 18:25:20 UTC Comment hidden (obsolete)
Comment 3 Tomás Cohen Arazi 2018-09-11 18:38:34 UTC
Created attachment 78565 [details] [review]
Bug 21334: Add bibliographic content type definitions

This patch adds the following content type definitions, to be used by
endpoint authors implementing MARC-related endpoints:

--------------------------------------
| Content-type             | Alias   |
|--------------------------|---------|
| application/marcxml+xml  | marcxml |
| application/marc-in-json | mij     |
| application/marc         | marc    |
--------------------------------------

Code using this aliases will use them like this:
- Suppose you want to output data in MARCXML format:

my $record = cool_method_that_returns_MARC_RECORD();
return $c->render( status => 200, format => 'marcxml', text => $record->as_xml_record );

Note: 'text' by defaults encodes output as UTF-8. If the encoding is not
UTF-8 you should encode the data on your own.

To test:
- Apply this patches
- Run:
  $ kshell
 k$ prove t/db_dependent/Koha/REST/V1.t
=> SUCCESS: Test pass!
- Sign off :-D
Comment 4 Tomás Cohen Arazi 2018-09-11 18:39:15 UTC
Fixed minor mistake on usage explanation.
Comment 5 Michal Denar 2018-09-12 12:39:37 UTC
Created attachment 78585 [details] [review]
Bug 21334: Add bibliographic content type definitions

This patch adds the following content type definitions, to be used by
endpoint authors implementing MARC-related endpoints:

--------------------------------------
| Content-type             | Alias   |
|--------------------------|---------|
| application/marcxml+xml  | marcxml |
| application/marc-in-json | mij     |
| application/marc         | marc    |
--------------------------------------

Code using this aliases will use them like this:
- Suppose you want to output data in MARCXML format:

my $record = cool_method_that_returns_MARC_RECORD();
return $c->render( status => 200, format => 'marcxml', text => $record->as_xml_record );

Note: 'text' by defaults encodes output as UTF-8. If the encoding is not
UTF-8 you should encode the data on your own.

To test:
- Apply this patches
- Run:
  $ kshell
 k$ prove t/db_dependent/Koha/REST/V1.t
=> SUCCESS: Test pass!
- Sign off :-D

Signed-off-by: Michal Denar <black23@gail.com>
Comment 6 Josef Moravec 2018-09-12 18:37:16 UTC
Created attachment 78599 [details] [review]
Bug 21334: Unit tests

This patch adds unit tests for the new content types being added.
It also adds tests for the 'json' overloading that already takes place
in V1.pm.

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 7 Josef Moravec 2018-09-12 18:37:26 UTC
Created attachment 78600 [details] [review]
Bug 21334: Add bibliographic content type definitions

This patch adds the following content type definitions, to be used by
endpoint authors implementing MARC-related endpoints:

--------------------------------------
| Content-type             | Alias   |
|--------------------------|---------|
| application/marcxml+xml  | marcxml |
| application/marc-in-json | mij     |
| application/marc         | marc    |
--------------------------------------

Code using this aliases will use them like this:
- Suppose you want to output data in MARCXML format:

my $record = cool_method_that_returns_MARC_RECORD();
return $c->render( status => 200, format => 'marcxml', text => $record->as_xml_record );

Note: 'text' by defaults encodes output as UTF-8. If the encoding is not
UTF-8 you should encode the data on your own.

To test:
- Apply this patches
- Run:
  $ kshell
 k$ prove t/db_dependent/Koha/REST/V1.t
=> SUCCESS: Test pass!
- Sign off :-D

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 8 Nick Clemens 2018-09-14 23:28:30 UTC
Awesome work all!

Pushed to master for 18.11
Comment 9 Martin Renvoize 2018-09-17 13:48:35 UTC
Enhancement, will not be backported to 18.05.x series.
Comment 10 Martin Renvoize 2018-09-20 14:04:03 UTC
Pushed to 18.05.x for 18.05.04.

After pushing bug 21116 I decided this one warranted backporting for the same reasons outlined on that bug.
Comment 11 Fridolin Somers 2018-09-24 10:35:34 UTC
Enhancement not pushed to 17.11.x
Comment 12 Justin Jack 2019-01-10 12:11:06 UTC
(In reply to Josef Moravec from comment #7)
> Created attachment 78600 [details] [review] [review]
> Bug 21334: Add bibliographic content type definitions
> 
> This patch adds the following content type definitions, to be used by
> endpoint authors implementing MARC-related endpoints:
> 
> --------------------------------------
> | Content-type             | Alias   |
> |--------------------------|---------|
> | application/marcxml+xml  | marcxml |
> | application/marc-in-json | mij     |
> | application/marc         | marc    |
> --------------------------------------
> 
> Code using this aliases will use them like this:
> - Suppose you want to output data in MARCXML format:
> 
> my $record = cool_method_that_returns_MARC_RECORD();
> return $c->render( status => 200, format => 'marcxml', text =>
> $record->as_xml_record );
> 
> Note: 'text' by defaults encodes output as UTF-8. If the encoding is not
> UTF-8 you should encode the data on your own.
> 
> To test:
> - Apply this patches
> - Run:
>   $ kshell
>  k$ prove t/db_dependent/Koha/REST/V1.t
> => SUCCESS: Test pass!
> - Sign off :-D
> 
> Signed-off-by: Michal Denar <https://whatstatus.co/guess-ill-die>
> 
> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

After pushing bug 21116 I decided this one warranted backporting for the same reasons outlined on that bug.