From d780305135b3b55e5000d9ba0155f72add60ceb1 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Fri, 19 Feb 2021 01:17:38 +0000 Subject: [PATCH] Bug 20028: Add OpenAPI spec Includes a test that validates the existence of all related properties. To test: 1. prove t/db_dependent/api/v1/patrons_export.t Sponsored-by: The National Library of Finland Signed-off-by: Michal Denar --- api/v1/swagger/definitions.json | 3 ++ api/v1/swagger/definitions/patron_export.json | 15 ++++++ api/v1/swagger/paths.json | 6 +++ api/v1/swagger/paths/patrons_export.json | 68 ++++++++++++++++++++++++++ api/v1/swagger/paths/public_patrons.json | 69 ++++++++++++++++++++++++++- 5 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 api/v1/swagger/definitions/patron_export.json create mode 100644 api/v1/swagger/paths/patrons_export.json diff --git a/api/v1/swagger/definitions.json b/api/v1/swagger/definitions.json index c12936736f..c3dbba98a7 100644 --- a/api/v1/swagger/definitions.json +++ b/api/v1/swagger/definitions.json @@ -71,6 +71,9 @@ "patron_balance": { "$ref": "definitions/patron_balance.json" }, + "patron_export": { + "$ref": "definitions/patron_export.json" + }, "quote": { "$ref": "definitions/quote.json" }, diff --git a/api/v1/swagger/definitions/patron_export.json b/api/v1/swagger/definitions/patron_export.json new file mode 100644 index 0000000000..89d6bc265b --- /dev/null +++ b/api/v1/swagger/definitions/patron_export.json @@ -0,0 +1,15 @@ +{ + "type": "array", + "items": { + "type": "object", + "properties": { + "data": { + "type": "object" + }, + "type": { + "type": "string" + } + } + }, + "additionalProperties": false +} diff --git a/api/v1/swagger/paths.json b/api/v1/swagger/paths.json index dd9562c2f1..e76eca01d0 100644 --- a/api/v1/swagger/paths.json +++ b/api/v1/swagger/paths.json @@ -122,6 +122,9 @@ "/patrons/{patron_id}/account/credits": { "$ref": "paths/patrons_account.json#/~1patrons~1{patron_id}~1account~1credits" }, + "/patrons/{patron_id}/export": { + "$ref": "paths/patrons_export.json#/~1patrons~1{patron_id}~1export" + }, "/patrons/{patron_id}/holds": { "$ref": "paths/patrons_holds.json#/~1patrons~1{patron_id}~1holds" }, @@ -149,6 +152,9 @@ "/public/biblios/{biblio_id}": { "$ref": "paths/biblios.json#/~1public~1biblios~1{biblio_id}" }, + "/public/patrons/{patron_id}/export": { + "$ref": "paths/public_patrons.json#/~1public~1patrons~1{patron_id}~1export" + }, "/public/patrons/{patron_id}/password": { "$ref": "paths/public_patrons.json#/~1public~1patrons~1{patron_id}~1password" }, diff --git a/api/v1/swagger/paths/patrons_export.json b/api/v1/swagger/paths/patrons_export.json new file mode 100644 index 0000000000..5741955cff --- /dev/null +++ b/api/v1/swagger/paths/patrons_export.json @@ -0,0 +1,68 @@ +{ + "/patrons/{patron_id}/export": { + "get": { + "x-mojo-to": "Patrons::Export#get", + "operationId": "getPatronExport", + "tags": [ + "patron" + ], + "parameters": [ + { + "$ref": "../parameters.json#/patron_id_pp" + }, + { + "$ref": "../parameters.json#/page" + }, + { + "$ref": "../parameters.json#/per_page" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "Patron's data export", + "schema": { + "$ref": "../definitions.json#/patron_export" + } + }, + "401": { + "description": "Authentication required", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "403": { + "description": "Access forbidden", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "404": { + "description": "Patron not found", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "503": { + "description": "Under maintenance", + "schema": { + "$ref": "../definitions.json#/error" + } + } + }, + "x-koha-authorization": { + "permissions": { + "borrowers": "edit_borrowers" + } + } + } + } +} diff --git a/api/v1/swagger/paths/public_patrons.json b/api/v1/swagger/paths/public_patrons.json index 5db073c4eb..f98bdb6b0f 100644 --- a/api/v1/swagger/paths/public_patrons.json +++ b/api/v1/swagger/paths/public_patrons.json @@ -1,4 +1,71 @@ { + "/public/patrons/{patron_id}/export": { + "get": { + "x-mojo-to": "Patrons::Export#get_public", + "operationId": "getPublicPatronExport", + "tags": [ + "patron" + ], + "parameters": [ + { + "$ref": "../parameters.json#/patron_id_pp" + }, + { + "$ref": "../parameters.json#/page" + }, + { + "$ref": "../parameters.json#/per_page" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "Patron's data export", + "schema": { + "$ref": "../definitions.json#/patron_export" + } + }, + "401": { + "description": "Authentication required", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "403": { + "description": "Access forbidden", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "404": { + "description": "Patron not found", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "503": { + "description": "Under maintenance", + "schema": { + "$ref": "../definitions.json#/error" + } + } + }, + "x-koha-authorization": { + "permissions": { + "borrowers": "edit_borrowers" + }, + "allow-owner": true + } + } + }, "/public/patrons/{patron_id}/password": { "post": { "x-mojo-to": "Patrons::Password#set_public", @@ -237,4 +304,4 @@ } } } -} \ No newline at end of file +} -- 2.11.0