From 1e551885b94eb4333473bd74f435251bd0fb3713 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Tue, 22 Nov 2022 16:06:31 +0100 Subject: [PATCH 1/6] Add start_index & limit to likes and comments --- doc/api.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/api.yaml b/doc/api.yaml index a8a2d2b..3617ddd 100644 --- a/doc/api.yaml +++ b/doc/api.yaml @@ -324,6 +324,20 @@ paths: $ref: "#/components/schemas/photo_id" required: true description: The ID of the photo. + - name: limit + in: query + schema: + type: integer + default: 25 + description: The number of elements to show. + required: false + - name: start_index + in: query + schema: + type: integer + default: 0 + description: The starting offset. + required: false responses: '200': description: Returns the user list @@ -589,6 +603,21 @@ paths: summary: Gets photo comments description: Gets the list of comments of a photo operationId: getPhotoComments + parameters: + - name: limit + in: query + schema: + type: integer + default: 25 + description: The number of elements to show. + required: false + - name: start_index + in: query + schema: + type: integer + default: 0 + description: The starting offset. + required: false security: - BearerAuth: [] responses: From a5c2bb155c273cae4c3b2eb29f86932ce9929635 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Tue, 22 Nov 2022 16:18:19 +0100 Subject: [PATCH 2/6] Separated user profile and user photos --- doc/api.yaml | 75 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 8 deletions(-) diff --git a/doc/api.yaml b/doc/api.yaml index 3617ddd..68b3412 100644 --- a/doc/api.yaml +++ b/doc/api.yaml @@ -479,6 +479,60 @@ paths: error: "Resource not found" /users/{user_id}/photos: + parameters: + - name: user_id + in: path + schema: + $ref: "#/components/schemas/uid" + required: true + description: The user ID of the user who uploads the photo. + + get: + tags: ["photos"] + summary: Returns user photos + description: Returns the list of photos uploaded by a user. + operationId: getUserPhotos + security: + - BearerAuth: [] + parameters: + - name: limit + in: query + schema: + type: integer + default: 25 + description: The number of elements to show. + required: false + - name: start_index + in: query + schema: + type: integer + default: 0 + description: The starting offset. + required: false + responses: + '200': + description: Returns the user photos list + content: + application/json: + schema: + $ref: "#/components/schemas/user_photo_stream" + '404': + description: User not found (or the authorized user is banned). + content: + application/json: + schema: + $ref: "#/components/schemas/generic_response" + example: + error: "Resource not found" + '400': + description: Bad request, there is an error in one of the parameters. + content: + application/json: + schema: + $ref: "#/components/schemas/generic_response" + example: + error: "Invalid limit or start_index" + post: tags: ["photos"] summary: Uploads a photo @@ -486,13 +540,6 @@ paths: operationId: uploadPhoto security: - BearerAuth: [] - parameters: - - name: user_id - in: path - schema: - $ref: "#/components/schemas/uid" - required: true - description: The user ID of the user who uploads the photo. requestBody: content: image/jpeg: @@ -823,6 +870,14 @@ components: type: integer example: 69 description: Number of following users. + liked_boolean: + type: boolean + example: true + description: Whether the user liked the photo. + photos_n: + type: integer + example: 90 + description: Number of photos. user_profile: type: object description: The profile of the user. @@ -834,7 +889,7 @@ components: following: $ref: "#/components/schemas/following_n" photos: - $ref: "#/components/schemas/user_photo_stream" + $ref: "#/components/schemas/photos_n" user_photo_stream: type: array minItems: 0 @@ -850,6 +905,8 @@ components: $ref: "#/components/schemas/upload_time" likes: $ref: "#/components/schemas/likes" + liked: + $ref: "#/components/schemas/liked_boolean" photo_stream: type: array minItems: 0 @@ -869,6 +926,8 @@ components: $ref: "#/components/schemas/upload_time" likes: $ref: "#/components/schemas/likes" + liked: + $ref: "#/components/schemas/liked_boolean" comments: type: array minItems: 0 From c0d7a7a1eeb0d30914120ffb2f61efb309d267bb Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Tue, 22 Nov 2022 16:51:16 +0100 Subject: [PATCH 3/6] Moved start_index & limit to schema --- doc/api.yaml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/api.yaml b/doc/api.yaml index 68b3412..287530c 100644 --- a/doc/api.yaml +++ b/doc/api.yaml @@ -327,15 +327,13 @@ paths: - name: limit in: query schema: - type: integer - default: 25 + $ref: "#/components/schemas/limit" description: The number of elements to show. required: false - name: start_index in: query schema: - type: integer - default: 0 + $ref: "#/components/schemas/start_index" description: The starting offset. required: false responses: @@ -498,15 +496,13 @@ paths: - name: limit in: query schema: - type: integer - default: 25 + $ref: "#/components/schemas/limit" description: The number of elements to show. required: false - name: start_index in: query schema: - type: integer - default: 0 + $ref: "#/components/schemas/start_index" description: The starting offset. required: false responses: @@ -654,15 +650,13 @@ paths: - name: limit in: query schema: - type: integer - default: 25 + $ref: "#/components/schemas/limit" description: The number of elements to show. required: false - name: start_index in: query schema: - type: integer - default: 0 + $ref: "#/components/schemas/start_index" description: The starting offset. required: false security: @@ -779,15 +773,13 @@ paths: - name: limit in: query schema: - type: integer - default: 25 + $ref: "#/components/schemas/limit" description: The number of elements to show. required: false - name: start_index in: query schema: - type: integer - default: 0 + $ref: "#/components/schemas/start_index" description: The starting offset. required: false responses: @@ -813,6 +805,14 @@ components: scheme: bearer schemas: + start_index: + type: integer + description: The starting offset. + default: 0 + limit: + type: integer + description: The number of elements to show. + default: 15 uid_name: type: object properties: From 5b2f6ed9de91cd17263b9c2d7fddb3e20435ee77 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Tue, 22 Nov 2022 16:52:50 +0100 Subject: [PATCH 4/6] Add maxItems everywhere --- doc/api.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/api.yaml b/doc/api.yaml index 287530c..36c6bdf 100644 --- a/doc/api.yaml +++ b/doc/api.yaml @@ -145,6 +145,7 @@ paths: schema: type: array minItems: 0 + maxItems: 100 description: The list of users that the user is following. items: $ref: "#/components/schemas/uid_name" @@ -344,6 +345,7 @@ paths: schema: type: array minItems: 0 + maxItems: 100 description: An array of users liking the photo. items: $ref: "#/components/schemas/uid_name" @@ -893,6 +895,7 @@ components: user_photo_stream: type: array minItems: 0 + maxItems: 100 description: An array of photos, upload time and likes. items: $ref: "#/components/schemas/user_photo_stream_item" @@ -910,6 +913,7 @@ components: photo_stream: type: array minItems: 0 + maxItems: 100 description: An array of photos, author, upload time and likes. items: $ref: "#/components/schemas/photo_stream_item" @@ -931,6 +935,7 @@ components: comments: type: array minItems: 0 + maxItems: 100 description: An array of comments. items: $ref : "#/components/schemas/comment_item" From 028ff36a676d05b0d45353470757033ae57c6e2d Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Tue, 22 Nov 2022 17:07:28 +0100 Subject: [PATCH 5/6] Add comments number to photo structures --- doc/api.yaml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/doc/api.yaml b/doc/api.yaml index 36c6bdf..04a6923 100644 --- a/doc/api.yaml +++ b/doc/api.yaml @@ -462,13 +462,7 @@ paths: username: "Maria" followers: 25 following: 32 - photos: - - photo_id: 2341 - upload_time: "2020-11-20T12:00:00Z" - likes: 2 - - photo_id: 2342 - upload_time: "2022-10-23T12:01:00Z" - likes: 5 + photos: 50 '404': description: User not found (or the authorized user is banned). content: @@ -793,12 +787,12 @@ paths: $ref: "#/components/schemas/photo_stream" example: - user_id: "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d" - - username: "Federicus" - - photo_id: 1520 - - upload_time: "2020-11-20T12:00:00Z" - - likes: 93 - - + username: "Federicus" + photo_id: 157 + upload_time: "2020-11-20T12:00:00Z" + likes: 93 + comments: 13 + liked: true components: securitySchemes: @@ -864,6 +858,10 @@ components: type: integer example: 90 description: Number of likes. + comments_n: + type: integer + example: 7 + description: Number of comments on the photo. followers_n: type: integer example: 420 @@ -908,6 +906,8 @@ components: $ref: "#/components/schemas/upload_time" likes: $ref: "#/components/schemas/likes" + comments: + $ref: "#/components/schemas/comments_n" liked: $ref: "#/components/schemas/liked_boolean" photo_stream: @@ -930,6 +930,8 @@ components: $ref: "#/components/schemas/upload_time" likes: $ref: "#/components/schemas/likes" + comments: + $ref: "#/components/schemas/comments_n" liked: $ref: "#/components/schemas/liked_boolean" comments: From 8b2d25dc2305016a03931d8d3849867a2597f76a Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Tue, 22 Nov 2022 17:13:31 +0100 Subject: [PATCH 6/6] Bump version to 3.0 --- doc/api.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api.yaml b/doc/api.yaml index 04a6923..e9995dd 100644 --- a/doc/api.yaml +++ b/doc/api.yaml @@ -4,9 +4,9 @@ info: description: |- Keep in touch with your friends by sharing photos of special moments, thanks to WASAPhoto! You can upload your photos directly from your PC, and they will be visible to everyone following you. - version: "2.0.0" + version: "3.0" tags: - - name: login + - name: logins description: Login API - name: username description: Operations related to username