Koha/api/v1/swagger/definitions/item.yaml
Tomas Cohen Arazi dab0260702 Bug 33161: Add +strings support to GET /items and /items/:item_id
This patch introduces the `api_strings_mapping` method to the
*Koha::Item* class, and makes the API spec for the following routes:

* GET /items
* GET /items/:item_id
* GET /acquisitions/orders

accept the new `+strings` parameter that can be passed through the
`x-koha-embed` header and was introduced by bug 26635. In the case of
/acquisitions/orders, you will need to use

x-koha-embed: items+strings

I introduce it here to highlight the flebility we introduced with bug
26635.

The `api_strings_mapping` method has its roots on the cool
`columns_to_str` method already present. The main differences:

* It is aware of the `public_read_list` for attributes so no hidden
  information is exposed.
* Attribute names get mapped for consistency with the API (e.g.
  `homebranch` is converted into `home_library_id`, etc).
* The data structure it returns includes information about the source
  for the descriptions (e.g. it it is an authorised value, then `type`
  will be `av`, and the related category information is returned so
  dropdowns and such can be built. The same goes for other types as
 `library`, `item_type` and `call_number_source`.

To test:
1. Apply this patch
2. Reload everything
3. Play with your favourite REST tool (e.g. Postman)
4. Try:
GET http://localhost:8081/api/v1/items
x-koha-embed: +strings
=> SUCCESS: You get a list of items, they include the new _strings
structure, and the contents make sense!
5. Repeat with a specific item:
GET http://localhost:8081/api/v1/items/14
x-koha-embed: +strings
=> SUCCESS: It all makes sense!
6. Sign off :-D

Sponsored-by: Virginia Polytechnic Institute and State University
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-03-10 10:20:09 -03:00

242 lines
5.8 KiB
YAML

---
type: object
properties:
item_id:
type: integer
description: Internal item identifier
biblio_id:
type: integer
description: Internal identifier for the parent bibliographic record
biblio: {}
external_id:
type:
- string
- "null"
description: The item's barcode
acquisition_date:
type:
- string
- "null"
format: date
description: The date the item was acquired
acquisition_source:
type:
- string
- "null"
description: Information about the acquisition source (it is not really a vendor id)
home_library_id:
type:
- string
- "null"
description: Internal library id for the library the item belongs to
purchase_price:
type:
- number
- "null"
description: Purchase price
replacement_price:
type:
- number
- "null"
description: Cost the library charges to replace the item (e.g. if lost)
replacement_price_date:
type:
- string
- "null"
format: date
description: The date the replacement price is effective from
last_checkout_date:
type:
- string
- "null"
format: date
description: The date the item was last checked out
last_seen_date:
type:
- string
- "null"
format: date
description: The date the item barcode was last scanned
not_for_loan_status:
type: integer
description: Authorized value defining why this item is not for loan
effective_not_for_loan_status:
type: integer
description: Authorized value defining why this item is not for not_for_loan_status
damaged_status:
type: integer
description: Authorized value defining this item as damaged
damaged_date:
type:
- string
- "null"
description: The date and time an item was last marked as damaged, NULL if not damaged
lost_status:
type: integer
description: Authorized value defining this item as lost
lost_date:
type:
- string
- "null"
format: date-time
description: The date and time an item was last marked as lost, NULL if not lost
withdrawn:
type: integer
description: Authorized value defining this item as withdrawn
withdrawn_date:
type:
- string
- "null"
format: date-time
description: The date and time an item was last marked as withdrawn, NULL if not
withdrawn
callnumber:
type:
- string
- "null"
description: Call number for this item
coded_location_qualifier:
type:
- string
- "null"
description: Coded location qualifier
checkouts_count:
type:
- integer
- "null"
description: Number of times this item has been checked out/issued
renewals_count:
type:
- integer
- "null"
description: Number of times this item has been renewed
holds_count:
type:
- integer
- "null"
description: Number of times this item has been placed on hold/reserved
restricted_status:
type:
- integer
- "null"
description: Authorized value defining use restrictions for this item
public_notes:
type:
- string
- "null"
description: Public notes on this item
internal_notes:
type:
- string
- "null"
description: Non-public notes on this item
holding_library_id:
type:
- string
- "null"
description: Library that is currently in possession item
timestamp:
type: string
format: date-time
description: Date and time this item was last altered
location:
type:
- string
- "null"
description: Authorized value for the shelving location for this item
permanent_location:
type:
- string
- "null"
description: Linked to the CART and PROC temporary locations feature, stores the
permanent shelving location
checked_out_date:
type:
- string
- "null"
format: date
description: Defines if item is checked out (NULL for not checked out, and checkout
date for checked out)
call_number_source:
type:
- string
- "null"
description: Classification source used on this item
call_number_sort:
type:
- string
- "null"
description: "?"
collection_code:
type:
- string
- "null"
description: Authorized value for the collection code associated with this item
materials_notes:
type:
- string
- "null"
description: Materials specified
uri:
type:
- string
- "null"
description: URL for the item
item_type_id:
type:
- string
- "null"
description: Itemtype defining the type for this item
effective_item_type_id:
type:
- string
- "null"
description: Effective itemtype defining the type for this item_id
extended_subfields:
type:
- string
- "null"
description: Additional 952 subfields in XML format
serial_issue_number:
type:
- string
- "null"
description: serial enumeration/chronology for the item
copy_number:
type:
- string
- "null"
description: Copy number
inventory_number:
type:
- string
- "null"
description: Inventory number
new_status:
type:
- string
- "null"
description: "'new' value, whatever free-text information."
exclude_from_local_holds_priority:
type: boolean
description: Exclude this item from local holds priority.
return_claims:
type: array
description: An array of all return claims associated with this item
return_claim:
type:
- object
- "null"
_strings:
type:
- object
- "null"
description: A return claims object if one exists that's unresolved
additionalProperties: false
required:
- item_id
- biblio_id
- not_for_loan_status
- damaged_status
- lost_status
- withdrawn