From 2238f2ed55a4f8bc5d9b90f672046f270e18fead Mon Sep 17 00:00:00 2001 From: Jacob O'Mara Date: Tue, 29 Oct 2024 10:59:58 +0000 Subject: [PATCH] Bug 38050: create public CRUD list endpoint definitions This patch creates the yaml definitions for the public CRUD enpoints for lists/virtualshelves Signed-off-by: Martin Renvoize --- api/v1/swagger/definitions/public_list.yaml | 57 +++++ api/v1/swagger/paths/public_lists.yaml | 229 ++++++++++++++++++++ api/v1/swagger/swagger.yaml | 6 +- 3 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 api/v1/swagger/definitions/public_list.yaml create mode 100644 api/v1/swagger/paths/public_lists.yaml diff --git a/api/v1/swagger/definitions/public_list.yaml b/api/v1/swagger/definitions/public_list.yaml new file mode 100644 index 00000000000..255b9aa952a --- /dev/null +++ b/api/v1/swagger/definitions/public_list.yaml @@ -0,0 +1,57 @@ +--- +type: object +properties: + list_id: + description: Internal identifier for the list + type: integer + readOnly: true + name: + description: List name + type: string + creation_date: + description: Date the list was created + type: string + format: date-time + readOnly: true + updated_on_date: + description: Date the list was last updated + type: string + format: date-time + readOnly: true + owner_id: + description: Internal identifier for the owning patron + type: integer + readOnly: true + allow_change_from_owner: + description: If the owner can change the contents + type: boolean + default: true + allow_change_from_others: + description: If others can change the contents + type: boolean + default: false + public: + description: If the list is public + type: boolean + default: true + default_sort_field: + description: The field this list is sorted on by default + type: string + default: 'title' + allow_change_from_permitted_staff: + description: If only permitted staff can change the contents + type: boolean + default: false + allow_change_from_staff: + description: If staff can change the contents + type: boolean + default: false +additionalProperties: false +required: + - list_id + - name + - creation_date + - updated_on_date + - allow_change_from_owner + - allow_change_from_others + - public diff --git a/api/v1/swagger/paths/public_lists.yaml b/api/v1/swagger/paths/public_lists.yaml new file mode 100644 index 00000000000..6545bd6bd67 --- /dev/null +++ b/api/v1/swagger/paths/public_lists.yaml @@ -0,0 +1,229 @@ +--- +"/public/lists": + get: + x-mojo-to: Lists#list_public + operationId: listListsPublic + description: "This resource returns a list of existing bibliographic lists." + summary: List bibliographic lists + tags: + - lists + parameters: + - name: only_mine + in: query + description: Only return the users' lists + required: false + type: string + - name: only_public + in: query + description: Only return public lists + 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" + - $ref: "../swagger.yaml#/parameters/request_id_header" + produces: + - application/json + responses: + "200": + description: A list of lists + schema: + type: array + items: + $ref: "../swagger.yaml#/definitions/public_list" + "400": + description: | + Bad request. Possible `error_code` attribute values: + + * `bad_request` + * `invalid_query` + * `only_mine_forbidden` + 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" + + post: + x-mojo-to: Lists#public_add + operationId: createPublicList + tags: + - lists + summary: Create a new list you own + description: "This resource creates a bibliographic list owned by the authenticated user." + produces: + - application/json + parameters: + - name: body + in: body + description: A JSON object containing information about the new list + required: true + schema: + $ref: "../swagger.yaml#/definitions/public_list" + responses: + "201": + description: List added + schema: + $ref: "../swagger.yaml#/definitions/public_list" + "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" + "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" + +/public/lists/{list_id}: + get: + x-mojo-to: Lists#public_get + operationId: getPublicList + description: "This resource returns information on a specific existing bibliographic list." + tags: + - lists + summary: Retrieve a specific public list or a list you own + produces: + - application/json + parameters: + - $ref: "../swagger.yaml#/parameters/list_id_pp" + responses: + "200": + description: OK + schema: + $ref: "../swagger.yaml#/definitions/public_list" + "400": + description: Bad request + schema: + $ref: "../swagger.yaml#/definitions/error" + "403": + description: Access forbidden + schema: + $ref: "../swagger.yaml#/definitions/error" + "404": + description: 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" + put: + x-mojo-to: Lists#public_update + operationId: updatePublicList + tags: + - lists + description: 'Update a specific list that you own' + summary: Update a specific list you own + produces: + - application/json + parameters: + - $ref: "../swagger.yaml#/parameters/list_id_pp" + - name: body + in: body + description: A list object + required: true + schema: + $ref: "../swagger.yaml#/definitions/list" + responses: + "200": + description: A list + schema: + $ref: "../swagger.yaml#/definitions/list" + "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: 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" + + delete: + x-mojo-to: Lists#public_delete + operationId: deletePublicList + tags: + - lists + summary: Delete a specific list you own + produces: + - application/json + parameters: + - $ref: "../swagger.yaml#/parameters/list_id_pp" + responses: + "204": + description: List deleted + "401": + description: Authentication required + schema: + $ref: "../swagger.yaml#/definitions/error" + "403": + description: Access forbidden + schema: + $ref: "../swagger.yaml#/definitions/error" + "404": + description: List 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" diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml index 307a0059e24..9a693eecca7 100644 --- a/api/v1/swagger/swagger.yaml +++ b/api/v1/swagger/swagger.yaml @@ -156,6 +156,8 @@ definitions: $ref: ./definitions/preservation_train_item.yaml preservation_processing: $ref: ./definitions/preservation_processing.yaml + public_list: + $ref: ./definitions/public_list.yaml quote: $ref: ./definitions/quote.yaml recall: @@ -516,7 +518,9 @@ paths: "/public/libraries/{library_id}": $ref: "./paths/libraries.yaml#/~1public~1libraries~1{library_id}" "/public/lists": - $ref: "./paths/lists.yaml#/~1public~1lists" + $ref: "./paths/public_lists.yaml#/~1public~1lists" + "/public/lists/{list_id}": + $ref: "./paths/public_lists.yaml#/~1public~1lists~1{list_id}" "/public/oauth/login/{provider_code}/{interface}": $ref: ./paths/public_oauth.yaml#/~1public~1oauth~1login~1{provider_code}~1{interface} "/public/patrons/{patron_id}/article_requests/{article_request_id}": -- 2.48.1