Bug 24908: Add text-formatted MARC support in /biblios/{biblio_id}
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 19 Mar 2020 15:04:39 +0000 (12:04 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 29 Apr 2020 16:13:36 +0000 (17:13 +0100)
This patch makes the route support requesting (through the Accept
header) the MARC record to be output as formatted text as in
$record->as_formatted.

To test:
1. Apply the unit tests patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/biblios.t
=> FAIL: Tests fail
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Try the route with your favourite API testing tool (Postman?)
=> SUCCESS: Accept: text/plain returns the expected results
=> SUCCESS: Wrong Accept header returns a list of valid formats, and
includes 'text/plain'.
6. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/REST/V1/Biblios.pm
api/v1/swagger/paths/biblios.json

index 80c7200..157282b 100644 (file)
@@ -82,13 +82,19 @@ sub get {
                     format => 'marc',
                     text   => $record->as_usmarc
                 },
+                txt => {
+                    status => 200,
+                    format => 'text/plain',
+                    text   => $record->as_formatted
+                },
                 any => {
                     status  => 406,
                     openapi => [
                         "application/json",
                         "application/marcxml+xml",
                         "application/marc-in-json",
-                        "application/marc"
+                        "application/marc",
+                        "text/plain"
                     ]
                 }
             );
index 530993f..4896b71 100644 (file)
@@ -15,7 +15,8 @@
         "application/json",
         "application/marcxml+xml",
         "application/marc-in-json",
-        "application/marc"
+        "application/marc",
+        "text/plain"
       ],
       "responses": {
         "200": {