メインコンテンツまでスキップ

User API 関数

このセクションでは、ユーザーに関連する操作について説明します。

ユーザーの作成

新しいユーザーアカウントを作成します。

エンドポイント: https://petstore3.swagger.io/api/v3/user

操作: POST

POST "https://petstore3.swagger.io/api/v3/user" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d '{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}'

レスポンス

| コード | 説明 | | default | 操作成功 |

レスポンス例

200: 操作成功

{
"id": 10,
"username": "theUser",
"firstName": "John",
"lastName": "James",
"email": "john@email.com",
"password": "12345",
"phone": "12345",
"userStatus": 1
}

パラメータ

リクエスト本文
名前タイプ説明
bodyUser オブジェクト(必須) 作成する User オブジェクト。

リストを使用したユーザーリストの作成

指定された入力リストを使用してユーザーのリストを作成します。

エンドポイント: https://petstore3.swagger.io/api/v3/user/createWithList

操作: POST

POST "https://petstore3.swagger.io/api/v3/user/createWithList" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d \
[
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}
]

レスポンス

コード説明
default操作成功
レスポンス例

200: 操作成功

{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}

パラメータ

リクエスト本文
名前タイプ説明
bodyUser オブジェクトの配列(必須) 作成する User オブジェクトのリスト。

ログイン

ユーザーをシステムにログインさせます。

エンドポイント: https://petstore3.swagger.io/api/v3/user/login

操作: GET

GET "https://petstore3.swagger.io/api/v3/user/login?username=string&password=string" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

レスポンス

コード説明
200操作成功
400無効なユーザー名/パスワードが提供されました
default予期しないエラー

レスポンス例

200: 操作成功

{
"message": "logged in user session:abcdef12345"
}

ヘッダー:

名前説明タイプ
X-Rate-Limitユーザーに許可されている1時間あたりの呼び出し回数。整数
X-Expires-Afterトークンが期限切れになるUTC日時。文字列

パラメータ

クエリパラメータ
名前タイプ説明
username文字列ログイン用のユーザー名。
password文字列平文でのログイン用パスワード。

ログアウト

現在ログインしているユーザーセッションをログアウトします。

エンドポイント: https://petstore3.swagger.io/api/v3/user/logout

操作: GET

GET "https://petstore3.swagger.io/api/v3/user/logout" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

レスポンス

コード説明
200操作成功
default操作成功
レスポンス例

200: 操作成功

{
"message": "Successfully logged out"
}

パラメータ

なし

ユーザー名によるユーザーの取得

ユーザー名でユーザーを取得します。

エンドポイント: https://petstore3.swagger.io/api/v3/user/{username}

操作: GET

GET "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

レスポンス

コード説明
200操作成功
400指定されたユーザー名が無効
404ユーザーが見つかりません
default予期しないエラー

200: 操作成功

{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}

パラメータ

パスパラメータ
名前タイプ説明
username文字列取得するユーザーのユーザー名。テストには "user" を使用してください。

ユーザーの更新

ユーザーを更新します。

エンドポイント: https://petstore3.swagger.io/api/v3/user/{username}

操作: PUT

PUT "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d '{
"id": 0,
"username": "user1",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}'

レスポンス

コード説明
200操作成功
400指定されたユーザーが無効
404ユーザーが見つかりません
default予期しないエラー

(更新が成功した場合、レスポンスボディなしで 200 コードが返されます。)

パラメータ

パスパラメータ
名前タイプ説明
username文字列更新するユーザーのユーザー名
リクエスト本文
名前タイプ説明
bodyUser オブジェクト(必須) 更新された情報を含む User オブジェクト。

ユーザーの削除

ユーザーを削除します。

エンドポイント: https://petstore3.swagger.io/api/v3/user/{username}

操作: DELETE

DELETE "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

レスポンス

コード説明
200ユーザーが削除されました
400指定されたユーザー名が無効
404ユーザーが見つかりません

(削除が成功した場合、レスポンスボディなしで 200 コードが返されます。)

パラメータ

パスパラメータ
名前タイプ説明
username文字列削除するユーザーのユーザー名