From de45bcf164bad7a8f94abeb48a6c73f27db10149 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 12 Jun 2023 15:46:29 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20openapi=E3=81=ABpost=E3=81=AE?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E3=82=92=E6=9B=B8=E3=81=84=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/openapi/api.yaml | 91 +++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/main/resources/openapi/api.yaml diff --git a/src/main/resources/openapi/api.yaml b/src/main/resources/openapi/api.yaml new file mode 100644 index 00000000..5d79479e --- /dev/null +++ b/src/main/resources/openapi/api.yaml @@ -0,0 +1,91 @@ +openapi: 3.0.3 +info: + title: Hideout API + description: Hideout API + version: 1.0.0 +servers: + - url: 'https://test-hideout.usbharu.dev/api/internal/v1' +paths: + /posts: + get: + summary: 権限に応じて投稿を返す + security: + - { } + - BearerAuth: [ ] + responses: + 200: + description: 成功 + content: + application/json: + schema: + $ref: "#/components/schemas/Post" + 401: + $ref: "#/components/responses/Unauthorized" + 403: + $ref: "#/components/responses/Forbidden" + 429: + $ref: "#/components/responses/TooManyRequests" + +components: + responses: + Unauthorized: + description: トークンが無効 + Forbidden: + description: 権限がない + NotFound: + description: 存在しないか権限がない + TooManyRequests: + description: レートリミット + + + schemas: + Post: + type: object + properties: + id: + type: integer + format: int64 + readOnly: true + userId: + type: integer + format: int64 + readOnly: true + overview: + type: string + text: + type: string + createdAt: + type: integer + format: int64 + readOnly: true + visibility: + type: string + enum: + - public + - unlisted + - followers + - direct + url: + type: string + format: uri + readOnly: true + repostId: + type: integer + format: int64 + readOnly: true + replyId: + type: integer + format: int64 + readOnly: true + sensitive: + type: boolean + apId: + type: string + format: url + readOnly: true + + + securitySchemes: + BearerAuth: + type: http + scheme: bearer From 51008148400789bbf7b7dcf6c96d8553f4292e25 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 12 Jun 2023 16:56:33 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20openapi=E3=81=ABpost=E3=81=AE?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E3=82=92=E6=9B=B8=E3=81=84=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/openapi/api.yaml | 116 +++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/src/main/resources/openapi/api.yaml b/src/main/resources/openapi/api.yaml index 5d79479e..0bfacf33 100644 --- a/src/main/resources/openapi/api.yaml +++ b/src/main/resources/openapi/api.yaml @@ -8,10 +8,57 @@ servers: paths: /posts: get: - summary: 権限に応じて投稿を返す + summary: 権限に応じて投稿一覧を返す security: - { } - BearerAuth: [ ] + responses: + 200: + description: 成功 + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/Post" + 401: + $ref: "#/components/responses/Unauthorized" + 403: + $ref: "#/components/responses/Forbidden" + 429: + $ref: "#/components/responses/TooManyRequests" + post: + summary: 投稿する + security: + - BearerAuth: [ ] + requestBody: + description: 投稿する内容 + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Post" + responses: + 200: + description: 成功 + headers: + Location: + description: 作成した投稿のURL + schema: + type: string + format: uri + 401: + $ref: "#/components/responses/Unauthorized" + 429: + $ref: "#/components/responses/TooManyRequests" + /posts/{postId}: + get: + summary: 権限に応じてIDの投稿を取得 + security: + - { } + - BearerAuth: [ ] + parameters: + - $ref: "#/components/parameters/postId" responses: 200: description: 成功 @@ -23,6 +70,57 @@ paths: $ref: "#/components/responses/Unauthorized" 403: $ref: "#/components/responses/Forbidden" + 404: + $ref: "#/components/responses/NotFound" + 429: + $ref: "#/components/responses/TooManyRequests" + /users/{userName}/posts: + get: + summary: 権限に応じてユーザーの投稿一覧を返す + security: + - { } + - BearerAuth: [ ] + parameters: + - $ref: "#/components/parameters/userName" + responses: + 200: + description: 成功 + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/Post" + 401: + $ref: "#/components/responses/Unauthorized" + 403: + $ref: "#/components/responses/Forbidden" + 429: + $ref: "#/components/responses/TooManyRequests" + + /users/{userName}/posts/{postId}: + get: + summary: 権限に応じてIDの投稿を取得 + description: userNameが間違っていても取得できます。 + security: + - { } + - BearerAuth: [ ] + parameters: + - $ref: "#/components/parameters/userName" + - $ref: "#/components/parameters/postId" + responses: + 200: + description: 成功 + content: + application/json: + schema: + $ref: "#/components/schemas/Post" + 401: + $ref: "#/components/responses/Unauthorized" + 403: + $ref: "#/components/responses/Forbidden" + 404: + $ref: "#/components/responses/NotFound" 429: $ref: "#/components/responses/TooManyRequests" @@ -37,6 +135,22 @@ components: TooManyRequests: description: レートリミット + parameters: + postId: + name: postId + in: path + description: 投稿ID + required: true + schema: + type: integer + format: int64 + userName: + name: userName + in: path + description: ユーザーIDまたはAcctなど @name@domain name@domain name + required: true + schema: + type: string schemas: Post: From ebe5f454440c1e1efc83e1a75b947f5b98332976 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 12 Jun 2023 17:33:31 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E3=81=9D=E3=81=AE=E4=BB=96?= =?UTF-8?q?=E3=81=AEopenapi=E3=82=82=E6=9B=B8=E3=81=84=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/openapi/api.yaml | 138 +++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 5 deletions(-) diff --git a/src/main/resources/openapi/api.yaml b/src/main/resources/openapi/api.yaml index 0bfacf33..f0a817dd 100644 --- a/src/main/resources/openapi/api.yaml +++ b/src/main/resources/openapi/api.yaml @@ -53,7 +53,7 @@ paths: $ref: "#/components/responses/TooManyRequests" /posts/{postId}: get: - summary: 権限に応じてIDの投稿を取得 + summary: 権限に応じてIDの投稿を返す security: - { } - BearerAuth: [ ] @@ -71,7 +71,7 @@ paths: 403: $ref: "#/components/responses/Forbidden" 404: - $ref: "#/components/responses/NotFound" + $ref: "#/components/responses/NotFoundOrForbidden" 429: $ref: "#/components/responses/TooManyRequests" /users/{userName}/posts: @@ -100,7 +100,7 @@ paths: /users/{userName}/posts/{postId}: get: - summary: 権限に応じてIDの投稿を取得 + summary: 権限に応じてIDの投稿を返す description: userNameが間違っていても取得できます。 security: - { } @@ -120,18 +120,124 @@ paths: 403: $ref: "#/components/responses/Forbidden" 404: - $ref: "#/components/responses/NotFound" + $ref: "#/components/responses/NotFoundOrForbidden" 429: $ref: "#/components/responses/TooManyRequests" + /users: + get: + summary: ユーザー一覧を返す + security: + - { } + responses: + 200: + description: 成功 + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/User" + + post: + summary: ユーザーを作成する + security: + - { } + requestBody: + description: 作成するユーザーの詳細 + required: true + content: + application/json: + schema: + type: object + properties: + username: + type: string + password: + type: string + responses: + 201: + description: ユーザーが作成された + headers: + Location: + description: 作成されたユーザーのURL + schema: + type: string + format: url + 400: + description: ユーザー名が既に仕様されている。またはリクエストが異常 + + /users/{userName}: + get: + summary: ユーザーの詳細を返す + security: + - { } + - BearerAuth: [ ] + parameters: + - $ref: "#/components/parameters/userName" + responses: + 200: + description: 成功 + content: + application/json: + schema: + $ref: "#/components/schemas/User" + 404: + $ref: "#/components/responses/NotFound" + + /users/{userName}/followers: + get: + summary: ユーザーのフォロワー一覧を返す + parameters: + - $ref: "#/components/parameters/userName" + responses: + 200: + description: 成功 + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/User" + post: + summary: ユーザーをフォローする + parameters: + - $ref: "#/components/parameters/userName" + responses: + 200: + description: 成功 + 202: + description: 受け付けられたが完了していない + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + + /users/{userName}/following: + get: + summary: ユーザーのフォロイー一覧を返す + parameters: + - $ref: "#/components/parameters/userName" + responses: + 200: + description: 成功 + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/User" + components: responses: Unauthorized: description: トークンが無効 Forbidden: description: 権限がない - NotFound: + NotFoundOrForbidden: description: 存在しないか権限がない + NotFound: + description: 存在しない TooManyRequests: description: レートリミット @@ -153,6 +259,28 @@ components: type: string schemas: + User: + type: object + properties: + id: + type: number + format: int64 + readOnly: true + name: + type: string + domain: + type: string + readOnly: true + screenName: + type: string + description: + type: string + url: + type: string + readOnly: true + createdAt: + type: number + readOnly: true Post: type: object properties: From 02a6d12063149e011dcf97d0049216f24b825f29 Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Mon, 12 Jun 2023 18:01:34 +0900 Subject: [PATCH 4/4] =?UTF-8?q?style:=20openapi=E3=81=AE=E3=82=B9=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/openapi/api.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/openapi/api.yaml b/src/main/resources/openapi/api.yaml index f0a817dd..5ff2768a 100644 --- a/src/main/resources/openapi/api.yaml +++ b/src/main/resources/openapi/api.yaml @@ -201,6 +201,8 @@ paths: $ref: "#/components/schemas/User" post: summary: ユーザーをフォローする + security: + - BearerAuth: [ ] parameters: - $ref: "#/components/parameters/userName" responses: