From 2a9142f9d3672e2d5bc7d175012fa055fd6f4353 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 Content-Type: text/plain; charset=utf-8 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: Marcel de Rooy --- 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 | 67 ++++++++++++++++++ 5 files changed, 159 insertions(+) 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 02dbc95c01..4dfab6c153 100644 --- a/api/v1/swagger/definitions.json +++ b/api/v1/swagger/definitions.json @@ -74,6 +74,9 @@ "patron_extended_attribute": { "$ref": "definitions/patron_extended_attribute.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 cdcd0368c5..0de79034b0 100644 --- a/api/v1/swagger/paths.json +++ b/api/v1/swagger/paths.json @@ -133,6 +133,9 @@ }, "/patrons/{patron_id}/extended_attributes/{extended_attribute_id}": { "$ref": "paths/patrons_extended_attributes.json#/~1patrons~1{patron_id}~1extended_attributes~1{extended_attribute_id}" + }, + "/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" @@ -161,6 +164,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 90d6cfe4c4..6f82e956f1 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", -- 2.20.1