From 4bcbbfce7b97373ea40ee71a3a1d83f9acf2353d Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Tue, 22 Nov 2016 16:41:09 +0200 Subject: [PATCH] Bug 16826: Availability Swagger definitions GET /availability/biblio/hold GET /availability/biblio/search GET /availability/item/checkout GET /availability/item/hold GET /availability/item/search --- api/v1/swagger/definitions.json | 9 + api/v1/swagger/definitions/availability.json | 18 ++ .../swagger/definitions/availability/biblio.json | 18 ++ api/v1/swagger/definitions/availability/item.json | 52 +++ .../swagger/definitions/availability/reason.json | 349 +++++++++++++++++++++ api/v1/swagger/parameters.json | 9 + api/v1/swagger/parameters/biblio.json | 12 + api/v1/swagger/parameters/item.json | 10 + api/v1/swagger/parameters/library.json | 8 + api/v1/swagger/paths.json | 15 + api/v1/swagger/paths/availability.json | 203 ++++++++++++ 11 files changed, 703 insertions(+) create mode 100644 api/v1/swagger/definitions/availability.json create mode 100644 api/v1/swagger/definitions/availability/biblio.json create mode 100644 api/v1/swagger/definitions/availability/item.json create mode 100644 api/v1/swagger/definitions/availability/reason.json create mode 100644 api/v1/swagger/parameters/biblio.json create mode 100644 api/v1/swagger/parameters/library.json create mode 100644 api/v1/swagger/paths/availability.json diff --git a/api/v1/swagger/definitions.json b/api/v1/swagger/definitions.json index a92fe4b..f213251 100644 --- a/api/v1/swagger/definitions.json +++ b/api/v1/swagger/definitions.json @@ -1,4 +1,13 @@ { + "availability": { + "$ref": "definitions/availability.json" + }, + "availability/biblio": { + "$ref": "definitions/availability/biblio.json" + }, + "availability/item": { + "$ref": "definitions/availability/item.json" + }, "city": { "$ref": "definitions/city.json" }, diff --git a/api/v1/swagger/definitions/availability.json b/api/v1/swagger/definitions/availability.json new file mode 100644 index 0000000..d7e6095 --- /dev/null +++ b/api/v1/swagger/definitions/availability.json @@ -0,0 +1,18 @@ +{ + "type": "object", + "properties": { + "available": { + "type": "boolean", + "description": "Availability status" + }, + "confirmations": { + "$ref": "./availability/reason.json" + }, + "notes": { + "$ref": "./availability/reason.json" + }, + "unavailabilities": { + "$ref": "./availability/reason.json" + } + } +} diff --git a/api/v1/swagger/definitions/availability/biblio.json b/api/v1/swagger/definitions/availability/biblio.json new file mode 100644 index 0000000..c1f2757 --- /dev/null +++ b/api/v1/swagger/definitions/availability/biblio.json @@ -0,0 +1,18 @@ +{ + "type": "object", + "properties": { + "biblionumber": { + "type": "integer", + "description": "Internal biblio identifier" + }, + "availability": { + "$ref": "../availability.json" + }, + "item_availabilities": { + "type": ["array", "null"], + "items": { + "$ref": "../availability/item.json" + } + } + } +} diff --git a/api/v1/swagger/definitions/availability/item.json b/api/v1/swagger/definitions/availability/item.json new file mode 100644 index 0000000..0289752 --- /dev/null +++ b/api/v1/swagger/definitions/availability/item.json @@ -0,0 +1,52 @@ +{ + "type": "object", + "properties": { + "availability": { + "$ref": "../availability.json" + }, + "barcode": { + "type": ["string", "null"], + "description": "item barcode" + }, + "biblioitemnumber": { + "type": "integer", + "description": "internally assigned biblio item identifier" + }, + "biblionumber": { + "type": "integer", + "description": "internally assigned biblio identifier" + }, + "enumchron": { + "type": ["string", "null"], + "description": "serial enumeration/chronology for the item" + }, + "holdQueueLength": { + "type": ["integer", "null"], + "description": "number of holdings placed on title/item" + }, + "holdingbranch": { + "type": ["string", "null"], + "description": "library that is currently in possession item" + }, + "homebranch": { + "type": ["string", "null"], + "description": "library that owns this item" + }, + "itemcallnumber": { + "type": ["string", "null"], + "description": "call number for this item" + }, + "itemnotes": { + "type": ["string", "null"], + "description": "public notes on this item" + }, + "itemnumber": { + "type": "integer", + "description": "internally assigned item identifier" + }, + "location": { + "type": ["string", "null"], + "description": "authorized value for the shelving location for this item" + } + } +} diff --git a/api/v1/swagger/definitions/availability/reason.json b/api/v1/swagger/definitions/availability/reason.json new file mode 100644 index 0000000..b62a518 --- /dev/null +++ b/api/v1/swagger/definitions/availability/reason.json @@ -0,0 +1,349 @@ +{ + "type": "object", + "properties": { + "Checkout": { + "type": "object", + "properties": {} + }, + "Checkout::DueDateBeforeNow": { + "description": "Given due date is already in the past.", + "properties": { + "duedate": { + "type": "string" + }, + "now": { + "type": "string" + } + } + }, + "Checkout::Fee": { + "type": "object", + "properties": { + "amount": { + "type": "number", + "description": "Amount of rental charge." + } + } + }, + "Checkout::HighHolds": { + "type": "object", + "description": "Loan period shortened for high held item.", + "properties": { + "num_holds": { + "type": "integer" + }, + "duration": { + "type": ["string", "null"] + }, + "returndate": { + "type": ["string", "null"] + } + } + }, + "Checkout::InvalidDueDate": { + "description": "Given due date is already in the past.", + "properties": { + "duedate": { + "type": "string" + } + } + }, + "Checkout::MaximumCheckoutsReached": { + "type": "object", + "properties": { + "max_checkouts_allowed": { + "type": "integer", + "description": "Maximum number of checkouts allowed." + }, + "current_checkout_count": { + "type": "integer", + "description": "Current checkout count for patron." + } + } + }, + "Checkout::MaximumOnsiteCheckoutsReached": { + "type": "object", + "properties": { + "max_onsite_checkouts": { + "type": "integer", + "description": "Maximum number of onsite checkouts allowed." + }, + "current_onsite_checkouts": { + "type": "integer", + "description": "Current onsite checkout count for patron." + } + } + }, + "Checkout::NoMoreRenewals": { + "type": "object", + "properties": {} + }, + "Checkout::NoMoreRenewalForOnsiteCheckouts": { + "type": "object", + "properties": {} + }, + "Checkout::OnsiteCheckoutsDisabled": { + "type": "object", + "properties": {} + }, + "Checkout::OnsiteCheckoutWillBeSwitched": { + "type": "object", + "properties": {} + }, + "Checkout::PreviouslyCheckedOut": { + "type": "object", + "properties": {} + }, + "Checkout::Renew": { + "type": "object", + "properties": {} + }, + "Checkout::BiblioAlreadyCheckedOut": { + "type": "object", + "properties": {} + }, + "Checkout::CheckedOutToAnotherPatron": { + "type": "object", + "properties": { + "borrowernumber": { + "$ref": "../../x-primitives.json#/borrowernumber" + }, + "date_due": { + "type": ["string", "null"] + } + } + }, + "Checkout::CheckinImpossibleInThisLibrary": { + "type": "object", + "properties": { + "branch_to_return": { + "$ref": "../../x-primitives.json#/branchcode" + } + } + }, + "Hold": { + "type": "object", + "properties": {} + }, + "Hold::CannotHoldFromOtherLibraries": { + "type": "object", + "properties": {} + }, + "Hold::Held": { + "type": "object", + "properties": { + "borrowernumber": { + "$ref": "../../x-primitives.json#/borrowernumber" + }, + "hold_queue_length": { + "type": "integer" + } + } + }, + "Hold::HeldForThisPatron": { + "type": "object", + "properties": {} + }, + "Hold::MaximumHoldsReached": { + "type": "object", + "properties": { + "max_holds_allowed": { + "type": "integer" + }, + "current_hold_count": { + "type": "integer" + } + } + }, + "Hold::MaximumHoldsForThisRecordReached": { + "type": "object", + "properties": { + "max_holds_allowed": { + "type": "integer" + }, + "current_hold_count": { + "type": "integer" + } + } + }, + "Hold::NotHoldable": { + "type": "object", + "properties": {} + }, + "Hold::Waiting": { + "type": "object", + "properties": { + "borrowernumber": { + "$ref": "../../x-primitives.json#/borrowernumber" + } + } + }, + "Item": { + "type": "object", + "properties": {} + }, + "Item::Damaged": { + "type": "object", + "properties": {} + }, + "Item::FromAnotherLibrary": { + "type": "object", + "properties": { + "itemhomebranch": { + "type": ["string", "null"] + } + } + }, + "Item::Lost": { + "type": "object", + "properties": { + "code": { + "type": ["string", "null"] + } + } + }, + "Item::NotForLoan": { + "type": "object", + "properties": { + "notforloan": { + "type": ["integer", "null"] + } + } + }, + "Item::NotForLoanForcing": { + "type": "object", + "properties": { + "notforloan": { + "type": ["integer", "null"] + } + } + }, + "Item::Ordered": { + "type": "object", + "properties": {} + }, + "Item::Restricted": { + "type": "object", + "properties": {} + }, + "Item::UnknownBarcode": { + "type": "object", + "properties": { + "barcode": { + "type": ["string", "null"] + } + } + }, + "Item::Withdrawn": { + "type": "object", + "properties": {} + }, + "ItemType": { + "type": "object", + "properties": {} + }, + "ItemType::NotForLoan": { + "type": "object", + "properties": { + "notforloan": { + "type": ["integer", "null"] + } + } + }, + "ItemType::Ordered": { + "type": "object", + "properties": {} + }, + "Patron": { + "type": "object", + "properties": {} + }, + "Patron::AgeRestricted": { + "type": "object", + "properties": { + "age_restriction": { + "type": ["string", "null"], + "description": "Age restriction, e.g. PEGI 16" + } + } + }, + "Patron::CardExpired": { + "type": "object", + "properties": { + "expiration_date": { + "type": ["string", "null"] + } + } + }, + "Patron::CardLost": { + "type": "object", + "properties": {} + }, + "Patron::Debarred": { + "type": "object", + "properties": { + "expiration_date": { + "type": ["string", "null"] + } + } + }, + "Patron::DebarredOverdue": { + "type": "object", + "properties": {} + }, + "Patron::Debt": { + "type": "object", + "properties": { + "maximum_allowed":{ + "type": ["number", "null"] + }, + "outstanding": { + "type": ["number", "null"] + } + } + }, + "Patron::DebtGuarantees": { + "type": "object", + "properties": { + "maximum_allowed":{ + "type": ["number", "null"] + }, + "outstanding": { + "type": ["number", "null"] + }, + "guarantees": { + "type": "array", + "items": { + "$ref": "../../x-primitives.json#/borrowernumber" + } + } + } + }, + "Patron::FromAnotherLibrary": { + "type": "object", + "properties": { + "patron_branch": { + "$ref": "../../x-primitives.json#/branchcode" + }, + "current_branch": { + "$ref": "../../x-primitives.json#/branchcode" + } + } + }, + "Patron::GoneNoAddress": { + "type": "object", + "properties": {} + }, + "Patron::OtherCharges": { + "type": "object", + "properties": { + "balance":{ + "type": ["number", "null"] + }, + "other_charges": { + "type": ["number", "null"] + } + } + } + } +} diff --git a/api/v1/swagger/parameters.json b/api/v1/swagger/parameters.json index f11031f..ed62fef 100644 --- a/api/v1/swagger/parameters.json +++ b/api/v1/swagger/parameters.json @@ -1,10 +1,16 @@ { + "biblionumbersQueryParam": { + "$ref": "parameters/biblio.json#/biblionumbersQueryParam" + }, "borrowernumberPathParam": { "$ref": "parameters/patron.json#/borrowernumberPathParam" }, "borrowernumberQueryParam": { "$ref": "parameters/patron.json#/borrowernumberQueryParam" }, + "branchcodeQueryParam": { + "$ref": "parameters/library.json#/branchcodeQueryParam" + }, "cityidPathParam": { "$ref": "parameters/city.json#/cityidPathParam" }, @@ -13,5 +19,8 @@ }, "itemnumberPathParam": { "$ref": "parameters/item.json#/itemnumberPathParam" + }, + "itemnumbersQueryParam": { + "$ref": "parameters/item.json#/itemnumbersQueryParam" } } diff --git a/api/v1/swagger/parameters/biblio.json b/api/v1/swagger/parameters/biblio.json new file mode 100644 index 0000000..b5d9534 --- /dev/null +++ b/api/v1/swagger/parameters/biblio.json @@ -0,0 +1,12 @@ +{ + "biblionumbersQueryParam": { + "name": "biblionumber", + "in": "query", + "description": "Internal biblios identifier", + "type": "array", + "items": { + "type": "integer" + }, + "collectionFormat": "ssv" + } +} diff --git a/api/v1/swagger/parameters/item.json b/api/v1/swagger/parameters/item.json index c215adb..409be6c 100644 --- a/api/v1/swagger/parameters/item.json +++ b/api/v1/swagger/parameters/item.json @@ -5,5 +5,15 @@ "description": "Internal item identifier", "required": true, "type": "integer" + }, + "itemnumbersQueryParam": { + "name": "itemnumber", + "in": "query", + "description": "Internal items identifier", + "type": "array", + "items": { + "type": "integer" + }, + "collectionFormat": "ssv" } } diff --git a/api/v1/swagger/parameters/library.json b/api/v1/swagger/parameters/library.json new file mode 100644 index 0000000..7bc63b4 --- /dev/null +++ b/api/v1/swagger/parameters/library.json @@ -0,0 +1,8 @@ +{ + "branchcodeQueryParam": { + "name": "branchcode", + "in": "query", + "description": "Branch identifier code", + "type": "string" + } +} diff --git a/api/v1/swagger/paths.json b/api/v1/swagger/paths.json index 73729c1..2bc21bf 100644 --- a/api/v1/swagger/paths.json +++ b/api/v1/swagger/paths.json @@ -1,4 +1,19 @@ { + "/availability/biblio/hold": { + "$ref": "paths/availability.json#/~1availability~1biblio~1hold" + }, + "/availability/biblio/search": { + "$ref": "paths/availability.json#/~1availability~1biblio~1search" + }, + "/availability/item/checkout": { + "$ref": "paths/availability.json#/~1availability~1item~1checkout" + }, + "/availability/item/hold": { + "$ref": "paths/availability.json#/~1availability~1item~1hold" + }, + "/availability/item/search": { + "$ref": "paths/availability.json#/~1availability~1item~1search" + }, "/cities": { "$ref": "paths/cities.json#/~1cities" }, diff --git a/api/v1/swagger/paths/availability.json b/api/v1/swagger/paths/availability.json new file mode 100644 index 0000000..d7ab4c6 --- /dev/null +++ b/api/v1/swagger/paths/availability.json @@ -0,0 +1,203 @@ +{ + "/availability/biblio/hold": { + "get": { + "operationId": "holdBiblioAvailability", + "tags": ["items", "availability"], + "parameters": [ + { "$ref": "../parameters.json#/biblionumbersQueryParam" }, + { "$ref": "../parameters.json#/borrowernumberQueryParam" }, + { "$ref": "../parameters.json#/branchcodeQueryParam"} + ], + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "Hold availability information for items of biblio.", + "schema": { + "type": "array", + "items": { "$ref": "../definitions.json#/availability~1biblio" } + } + }, + "400": { + "description": "Missing or invalid parameters", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "401": { + "description": "Authentication required", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "../definitions.json#/error" + } + } + } + } + }, + "/availability/biblio/search": { + "get": { + "operationId": "searchBiblioAvailability", + "tags": ["items", "availability"], + "parameters": [ + { "$ref": "../parameters.json#/biblionumbersQueryParam" } + ], + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "Availability information in search context for items of biblio.", + "schema": { + "type": "array", + "items": { "$ref": "../definitions.json#/availability~1biblio" } + } + }, + "400": { + "description": "Missing or invalid parameters", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "../definitions.json#/error" + } + } + } + } + }, + "/availability/item/checkout": { + "get": { + "operationId": "checkoutItemAvailability", + "tags": ["items", "availability"], + "parameters": [ + { "$ref": "../parameters.json#/itemnumbersQueryParam" }, + { "$ref": "../parameters.json#/borrowernumberQueryParam" } + ], + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "Checkout availability information for specific item(s).", + "schema": { + "type": "array", + "items": { "$ref": "../definitions.json#/availability~1item" } + } + }, + "400": { + "description": "Missing or invalid parameters", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "401": { + "description": "Authentication required", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "../definitions.json#/error" + } + } + } + } + }, + "/availability/item/hold": { + "get": { + "operationId": "holdItemAvailability", + "tags": ["items", "availability"], + "parameters": [ + { "$ref": "../parameters.json#/itemnumbersQueryParam" }, + { "$ref": "../parameters.json#/borrowernumberQueryParam" }, + { "$ref": "../parameters.json#/branchcodeQueryParam"} + ], + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "Hold availability information for specific item(s).", + "schema": { + "type": "array", + "items": { "$ref": "../definitions.json#/availability~1item" } + } + }, + "400": { + "description": "Missing or invalid parameters", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "401": { + "description": "Authentication required", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "403": { + "description": "Forbidden", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "../definitions.json#/error" + } + } + } + } + }, + "/availability/item/search": { + "get": { + "operationId": "searchItemAvailability", + "tags": ["items", "availability"], + "parameters": [ + { "$ref": "../parameters.json#/itemnumbersQueryParam" } + ], + "consumes": ["application/json"], + "produces": ["application/json"], + "responses": { + "200": { + "description": "Availability information in search context for specific item(s).", + "schema": { + "type": "array", + "items": { "$ref": "../definitions.json#/availability~1item" } + } + }, + "400": { + "description": "Missing or invalid parameters", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "../definitions.json#/error" + } + } + } + } + } +} -- 1.9.1