Merge pull request #21 from usbharu/feature/openapi

Feature/openapi
This commit is contained in:
usbharu 2023-06-14 13:12:18 +09:00 committed by GitHub
commit 9c5da79389
1 changed files with 335 additions and 0 deletions

View File

@ -0,0 +1,335 @@
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:
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: 成功
content:
application/json:
schema:
$ref: "#/components/schemas/Post"
401:
$ref: "#/components/responses/Unauthorized"
403:
$ref: "#/components/responses/Forbidden"
404:
$ref: "#/components/responses/NotFoundOrForbidden"
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/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: ユーザーをフォローする
security:
- BearerAuth: [ ]
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: 権限がない
NotFoundOrForbidden:
description: 存在しないか権限がない
NotFound:
description: 存在しない
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:
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:
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