Tomas Cohen Arazi
35e9ac9b0a
This patch adds a test for well defined 400 responses on all verbs and paths on the API spec. The tests verify: * Presence of 400 response definition * The description must start with 'Bad request' (needs coding guideline) * If DBIC queries are allowed on the route, then `invalid_query` needs to be mentioned in the description. All routes get fixed to make the tests pass. To test: 1. Apply this patch 2. Run: $ ktd --shell k$ yarn api:bundle k$ prove xt/api.t => SUCCESS: Tests pass! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
686 lines
20 KiB
YAML
686 lines
20 KiB
YAML
---
|
|
/preservation/trains:
|
|
get:
|
|
x-mojo-to: Preservation::Trains#list
|
|
operationId: listPreservationTrains
|
|
tags:
|
|
- preservation
|
|
summary: List trains
|
|
produces:
|
|
- application/json
|
|
parameters:
|
|
- description: Case insensitive search on train id
|
|
in: query
|
|
name: train_id
|
|
required: false
|
|
type: integer
|
|
- description: Case insensitive search on train name
|
|
in: query
|
|
name: name
|
|
required: false
|
|
type: string
|
|
- description: Case insensitive search on train description
|
|
in: query
|
|
name: description
|
|
required: false
|
|
type: string
|
|
- description: Case insensitive search on not for loan value
|
|
in: query
|
|
name: not_for_loan
|
|
required: false
|
|
type: string
|
|
- description: Case insensitive search on train creation date
|
|
in: query
|
|
name: created_on
|
|
required: false
|
|
type: string
|
|
- description: Case insensitive search on train closing date
|
|
in: query
|
|
name: closed_on
|
|
required: false
|
|
type: string
|
|
- description: Case insensitive search on train sent date
|
|
in: query
|
|
name: sent_on
|
|
required: false
|
|
type: string
|
|
- description: Case insensitive search on train receiving date
|
|
in: query
|
|
name: received_on
|
|
required: false
|
|
type: string
|
|
- $ref: "../swagger.yaml#/parameters/match"
|
|
- $ref: "../swagger.yaml#/parameters/order_by"
|
|
- $ref: "../swagger.yaml#/parameters/page"
|
|
- $ref: "../swagger.yaml#/parameters/per_page"
|
|
- $ref: "../swagger.yaml#/parameters/q_param"
|
|
- $ref: "../swagger.yaml#/parameters/q_body"
|
|
responses:
|
|
200:
|
|
description: A list of trains
|
|
schema:
|
|
items:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train"
|
|
type: array
|
|
"400":
|
|
description: |
|
|
Bad request. Possible `error_code` attribute values:
|
|
|
|
* `invalid_query`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
403:
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
500:
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
503:
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|
|
post:
|
|
x-mojo-to: Preservation::Trains#add
|
|
operationId: addPreservationTrains
|
|
tags:
|
|
- preservation
|
|
summary: Add train
|
|
consumes:
|
|
- application/json
|
|
produces:
|
|
- application/json
|
|
parameters:
|
|
- description: A JSON object containing information about the new train
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train"
|
|
responses:
|
|
201:
|
|
description: A successfully created train
|
|
schema:
|
|
items:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train"
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
401:
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
403:
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
404:
|
|
description: Ressource not found
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
409:
|
|
description: Conflict in creating resource
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
413:
|
|
description: Payload too large
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
500:
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
503:
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|
|
"/preservation/trains/{train_id}":
|
|
get:
|
|
x-mojo-to: Preservation::Trains#get
|
|
operationId: getPreservationTrains
|
|
tags:
|
|
- preservation
|
|
summary: Get train
|
|
produces:
|
|
- application/json
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_id_pp"
|
|
- name: x-koha-embed
|
|
in: header
|
|
required: false
|
|
description: Embed list sent as a request header
|
|
type: array
|
|
items:
|
|
type: string
|
|
enum:
|
|
- items
|
|
- items.attributes
|
|
- items.attributes+strings
|
|
- items.attributes.processing_attribute
|
|
- items.processing
|
|
- default_processing
|
|
- default_processing.attributes
|
|
collectionFormat: csv
|
|
responses:
|
|
200:
|
|
description: A train
|
|
schema:
|
|
items:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train"
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
401:
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
403:
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
404:
|
|
description: Ressource not found
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
500:
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
503:
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|
|
put:
|
|
x-mojo-to: Preservation::Trains#update
|
|
operationId: updatePreservationTrains
|
|
tags:
|
|
- preservation
|
|
summary: Update train
|
|
consumes:
|
|
- application/json
|
|
produces:
|
|
- application/json
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_id_pp"
|
|
- name: body
|
|
in: body
|
|
description: A JSON object containing new information about existing train
|
|
required: true
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train"
|
|
responses:
|
|
200:
|
|
description: A successfully updated train
|
|
schema:
|
|
items:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train"
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
403:
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
404:
|
|
description: Ressource not found
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
409:
|
|
description: Conflict in updating resource
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
413:
|
|
description: Payload too large
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
500:
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
503:
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|
|
delete:
|
|
x-mojo-to: Preservation::Trains#delete
|
|
operationId: deletePreservationTrains
|
|
tags:
|
|
- preservation
|
|
summary: Delete train
|
|
produces:
|
|
- application/json
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_id_pp"
|
|
responses:
|
|
204:
|
|
description: Train deleted
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
401:
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
403:
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
404:
|
|
description: Ressource not found
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
409:
|
|
description: Conflict in deleting resource
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
500:
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
503:
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|
|
"/preservation/trains/{train_id}/items":
|
|
post:
|
|
x-mojo-to: Preservation::Trains#add_item
|
|
operationId: addItemToTrain
|
|
tags:
|
|
- preservation
|
|
summary: Add item to train
|
|
consumes:
|
|
- application/json
|
|
produces:
|
|
- application/json
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_id_pp"
|
|
- description: An item
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train_item"
|
|
responses:
|
|
201:
|
|
description: A successfully added item
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train_item"
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
401:
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
403:
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
404:
|
|
description: Ressource not found
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
409:
|
|
description: Conflict in creating resource
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
413:
|
|
description: Payload too large
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
500:
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
503:
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|
|
"/preservation/trains/{train_id}/items/batch":
|
|
post:
|
|
x-mojo-to: Preservation::Trains#add_items
|
|
operationId: addItemsToTrain
|
|
tags:
|
|
- preservation
|
|
summary: Add items to train
|
|
consumes:
|
|
- application/json
|
|
produces:
|
|
- application/json
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_id_pp"
|
|
- description: A list of items
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
type: array
|
|
items:
|
|
type: object
|
|
responses:
|
|
201:
|
|
description: A successfully added list of items
|
|
schema:
|
|
type: array
|
|
items:
|
|
type: object
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
401:
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
403:
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
404:
|
|
description: Ressource not found
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
409:
|
|
description: Conflict in creating resource
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
413:
|
|
description: Payload too large
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
500:
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
503:
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|
|
"/preservation/trains/{train_id}/items/{train_item_id}":
|
|
put:
|
|
x-mojo-to: Preservation::Trains#update_item
|
|
operationId: updateItemFromTrain
|
|
tags:
|
|
- preservation
|
|
summary: Update item from train
|
|
consumes:
|
|
- application/json
|
|
produces:
|
|
- application/json
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_id_pp"
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_item_id_pp"
|
|
- description: An item
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train_item"
|
|
- name: x-koha-embed
|
|
in: header
|
|
required: false
|
|
description: Embed list sent as a request header
|
|
type: array
|
|
items:
|
|
type: string
|
|
enum:
|
|
- attributes
|
|
collectionFormat: csv
|
|
responses:
|
|
200:
|
|
description: A successfully updated item
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train_item"
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
403:
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
404:
|
|
description: Ressource not found
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
409:
|
|
description: Conflict in updating resource
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
413:
|
|
description: Payload too large
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
500:
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
503:
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|
|
delete:
|
|
x-mojo-to: Preservation::Trains#remove_item
|
|
operationId: removeItemFromTrain
|
|
tags:
|
|
- preservation
|
|
summary: Remove item from train
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_id_pp"
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_item_id_pp"
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"204":
|
|
description: Item removed
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"401":
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"403":
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"404":
|
|
description: Item not found
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"500":
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
"503":
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|
|
get:
|
|
x-mojo-to: Preservation::Trains#get_item
|
|
operationId: getItemFromPreservationTrains
|
|
tags:
|
|
- preservation
|
|
summary: Get item from train
|
|
produces:
|
|
- application/json
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_id_pp"
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_item_id_pp"
|
|
- name: x-koha-embed
|
|
in: header
|
|
required: false
|
|
description: Embed list sent as a request header
|
|
type: array
|
|
items:
|
|
type: string
|
|
enum:
|
|
- attributes
|
|
- catalogue_item
|
|
- catalogue_item.biblio
|
|
collectionFormat: csv
|
|
responses:
|
|
200:
|
|
description: An item in train
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train_item"
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
401:
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
403:
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
404:
|
|
description: Ressource not found
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
500:
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
503:
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|
|
|
|
"/preservation/trains/{train_id}/items/{train_item_id}/copy":
|
|
post:
|
|
x-mojo-to: Preservation::Trains#copy_item
|
|
operationId: copyItemToAnotherTrain
|
|
tags:
|
|
- preservation
|
|
summary: Copy an item to an other train
|
|
consumes:
|
|
- application/json
|
|
produces:
|
|
- application/json
|
|
parameters:
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_id_pp"
|
|
- $ref: "../swagger.yaml#/parameters/preservation_train_item_id_pp"
|
|
- description: The train_id of the new train
|
|
in: body
|
|
name: body
|
|
required: true
|
|
schema:
|
|
type: object
|
|
properties:
|
|
train_id:
|
|
description: Train id
|
|
type: integer
|
|
additionalProperties: false
|
|
responses:
|
|
201:
|
|
description: A successfully copied item
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/preservation_train_item"
|
|
"400":
|
|
description: Bad request
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
401:
|
|
description: Authentication required
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
403:
|
|
description: Access forbidden
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
404:
|
|
description: Ressource not found
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
409:
|
|
description: Conflict in creating resource
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
413:
|
|
description: Payload too large
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
500:
|
|
description: |
|
|
Internal server error. Possible `error_code` attribute values:
|
|
|
|
* `internal_server_error`
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
503:
|
|
description: Under maintenance
|
|
schema:
|
|
$ref: "../swagger.yaml#/definitions/error"
|
|
x-koha-authorization:
|
|
permissions:
|
|
preservation: 1
|