Koha/api/v1/swagger/paths/authorities.yaml
Tomas Cohen Arazi 531d03e811
Bug 31795: (QA follow-up) Use x-koha-override header
Despite its title, this patch does a couple more things.

1. The tests are rewritten to cover more things, and also to avoid
   deleting all authorities inside the transaction. It is really not
   required.
2. It makes the endpoint rely on the already generically implemented
   x-koha-override header, which is intended for the same use case as
   x-confirm-not-duplicate is for.
3. It changes the return codes to match the coding guidelines [1]
4. Only checks for duplicates if no override passed.

To test:
1. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/authorities.t
=> SUCCESS: Tests pass!
2. Apply this follow-up
3. Repeat 1
=> SUCCESS: Tests pass!
4. Sign off :-D

[1] https://wiki.koha-community.org/wiki/Coding_Guidelines_-_API#SWAGGER3.2.1_POST

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-05-05 10:18:43 -03:00

165 lines
4.6 KiB
YAML

---
"/authorities":
post:
x-mojo-to: Authorities#add
operationId: addAuthority
tags:
- authorities
summary: Add authority
description: |
Add an authority record to Koha. An optional `x-authority-type`
may be passed to specify the cataloguing framework to be used (instead
of the default).
The request body is expected to contain a MARC record in the format specified in
the `Content-type` header you pass. Possible values for this header and the corresponding
record formats expected are listed below:
* application/marcxml+xml: MARCXML
* application/marc-in-json: MARC-in-JSON
* application/marc: Raw USMARC binary data
parameters:
- $ref: "../swagger.yaml#/parameters/authority_type_header"
- name: x-koha-override
in: header
required: false
description: Overrides list sent as a request header
type: array
items:
type: string
enum:
- any
- duplicate
collectionFormat: csv
responses:
"201":
description: An authority
"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"
"406":
description: Not acceptable
schema:
type: array
description: Accepted content-types
items:
type: string
"409":
description: |
Conflict creating the resource. Possible `error_code` attribute values:
* `duplicate`
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:
editcatalogue: edit_catalogue
"/authorities/{authority_id}":
get:
x-mojo-to: Authorities#get
operationId: getAuthority
tags:
- authorities
summary: Get authority
parameters:
- $ref: "../swagger.yaml#/parameters/authority_id_pp"
produces:
- application/json
- application/marcxml+xml
- application/marc-in-json
- application/marc
- text/plain
responses:
"200":
description: An authority
"401":
description: Authentication required
schema:
$ref: "../swagger.yaml#/definitions/error"
"403":
description: Access forbidden
schema:
$ref: "../swagger.yaml#/definitions/error"
"404":
description: Authority not found
schema:
$ref: "../swagger.yaml#/definitions/error"
"406":
description: Not acceptable
schema:
type: array
description: Accepted content-types
items:
type: string
"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:
catalogue: "1"
delete:
x-mojo-to: Authorities#delete
operationId: deleteAuthority
tags:
- authorities
summary: Delete authority
parameters:
- $ref: "../swagger.yaml#/parameters/authority_id_pp"
produces:
- application/json
responses:
"204":
description: Authority deleted
schema:
type: string
"401":
description: Authentication required
schema:
$ref: "../swagger.yaml#/definitions/error"
"403":
description: Access forbidden
schema:
$ref: "../swagger.yaml#/definitions/error"
"404":
description: Authority not found
schema:
$ref: "../swagger.yaml#/definitions/error"
"500":
description: Internal error
schema:
$ref: "../swagger.yaml#/definitions/error"
"503":
description: Under maintenance
schema:
$ref: "../swagger.yaml#/definitions/error"
x-koha-authorization:
permissions:
editauthorities: "1"