From a411f7999911aa2025c449cbb69f72828eb93c82 Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Fri, 4 Oct 2019 16:58:33 -0300
Subject: [PATCH] Bug 17314: (QA follow-up) Adjust spec

This patch makes the exposed attribute names match what is defined in
the internal mapping in the code, and also the query parameters.

It also:
- Makes 'status' an enum, as we know the list of possible values/codes...
- Removes allow-owner and allow-guarantor, as said before, endpoints in
/public namespace are allowed to use those. I didn't go and write those
endpoints becuase I wasn't sure about the restrictions that apply in the
OPAC and might differ from the ones in the staff interface.
- Some numeric values are marked as such
- Dates are strings in OpenAPI, but there's a way to specify the format
inside the string: "format": "date". Use it
---
 api/v1/swagger/definitions/suggestion.json | 18 +++++++++++++---
 api/v1/swagger/paths/suggestions.json      | 34 +++++++++++++++---------------
 2 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/api/v1/swagger/definitions/suggestion.json b/api/v1/swagger/definitions/suggestion.json
index 57dcaac1cc..3a9c4c828f 100644
--- a/api/v1/swagger/definitions/suggestion.json
+++ b/api/v1/swagger/definitions/suggestion.json
@@ -11,6 +11,7 @@
     },
     "suggested_date": {
       "type": ["string", "null"],
+      "format": "date",
       "description": "the suggestion was submitted"
     },
     "managed_by": {
@@ -19,6 +20,7 @@
     },
     "managed_date": {
       "type": ["string", "null"],
+      "format": "date",
       "description": "date the suggestion was updated"
     },
     "accepted_by": {
@@ -27,6 +29,7 @@
     },
     "accepted_date": {
       "type": ["string", "null"],
+      "format": "date",
       "description": "date the suggestion was marked as accepted"
     },
     "rejected_by": {
@@ -35,11 +38,18 @@
     },
     "rejected_date": {
       "type": ["string", "null"],
+      "format": "date",
       "description": "date the suggestion was marked as rejected"
     },
     "status": {
       "type": "string",
-      "description": "suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED)"
+      "description": "Suggestion status",
+      "enum": [
+        "ASKED",
+        "CHECKED",
+        "ACCEPTED",
+        "REJECTED"
+      ]
     },
     "note": {
       "type": ["string", "null"],
@@ -55,6 +65,7 @@
     },
     "copyright_date": {
       "type": ["string", "null"],
+      "format": "date",
       "description": "copyright date of the suggested item"
     },
     "publisher_code": {
@@ -63,6 +74,7 @@
     },
     "date_created": {
       "type": ["string", "null"],
+      "format": "date",
       "description": "date created"
     },
     "volume_desc": {
@@ -118,10 +130,10 @@
       "description": "suggested currency for the suggested price"
     },
     "item_price": {
-      "type": ["string", "null"],
+      "type": ["number", "null"],
       "description": "suggested price"
     },
-    "total": {
+    "total_price": {
       "type": ["string", "null"],
       "description": "suggested total cost (price*quantity updated for currency)"
     }
diff --git a/api/v1/swagger/paths/suggestions.json b/api/v1/swagger/paths/suggestions.json
index 091f5be01b..e7cc622e88 100644
--- a/api/v1/swagger/paths/suggestions.json
+++ b/api/v1/swagger/paths/suggestions.json
@@ -6,40 +6,46 @@
       "tags": ["patrons", "suggestions"],
       "parameters": [
         {
-          "name": "suggestionid",
+          "name": "suggestion_id",
           "in": "query",
           "type": "integer",
           "description": "Internal suggestion identifier"
         },
         {
-          "name": "suggestedby",
+          "name": "suggested_by",
           "in": "query",
           "type": "integer",
           "description": "patron_id for the person making the suggestion, foreign key linking to the borrowers table"
         },
         {
-          "name": "managedby",
+          "name": "managed_by",
           "in": "query",
           "type": "integer",
           "description": "patron_id for the librarian managing the suggestion, foreign key linking to the borrowers table"
         },
         {
-          "name": "acceptedby",
+          "name": "accepted_by",
           "in": "query",
           "type": "integer",
           "description": "patron_id for the librarian who accepted the suggestion, foreign key linking to the borrowers table"
         },
         {
-          "name": "rejectedby",
+          "name": "rejected_by",
           "in": "query",
           "type": "integer",
           "description": "patron_id for the librarian who rejected the suggestion, foreign key linking to the borrowers table"
         },
         {
-          "name": "STATUS",
+          "name": "status",
           "in": "query",
           "type": "string",
-          "description": "suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED)"
+          "description": "Suggestion status",
+          "enum": [
+            "ASKED",
+            "CHECKED",
+            "ACCEPTED",
+            "REJECTED"
+          ]
         },
         {
           "name": "author",
@@ -54,19 +60,19 @@
           "description": "title of the suggested item"
         },
         {
-          "name": "publishercode",
+          "name": "publisher_code",
           "in": "query",
           "type": "string",
           "description": "publisher of the suggested item"
         },
         {
-          "name": "date",
+          "name": "date_created",
           "in": "query",
           "type": "string",
           "description": "date created"
         },
         {
-          "name": "publicationyear",
+          "name": "publication_year",
           "in": "query",
           "type": "string",
           "description": "year of publication"
@@ -84,7 +90,7 @@
           "description": "collection name for the suggested item"
         },
         {
-          "name": "itemtype",
+          "name": "item_type",
           "in": "query",
           "type": "string",
           "description": "suggested item type"
@@ -111,7 +117,6 @@
         }
       },
       "x-koha-authorization": {
-        "allow-owner": true,
         "permissions": {
           "acquisition": "1"
         }
@@ -160,7 +165,6 @@
         }
       },
       "x-koha-authorization": {
-        "allow-owner": true,
         "permissions": {
           "acquisition": "1"
         }
@@ -200,8 +204,6 @@
         }
       },
       "x-koha-authorization": {
-        "allow-owner": true,
-        "allow-guarantor": true,
         "permissions": {
           "acquisition": "1"
         }
@@ -258,7 +260,6 @@
         }
       },
       "x-koha-authorization": {
-        "allow-owner": true,
         "permissions": {
           "acquisition": "1"
         }
@@ -301,7 +302,6 @@
         }
       },
       "x-koha-authorization": {
-        "allow-owner": true,
         "permissions": {
           "acquisition": "1"
         }
-- 
2.11.0