User API 関数
このセクションでは、ユーザーに関連する操作について説明します。
ユーザーの作成
新しいユーザーアカウントを作成します。
エンドポイント: https://petstore3.swagger.io/api/v3/user
操作: POST
例
- API キー
- OAuth 2.0
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
}'
POST "https://petstore3.swagger.io/api/v3/user" \
-H "accept: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>" \
-H "Content-Type: application/json" \
-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
}
パラメータ
リクエスト本文
| 名前 | タイプ | 説明 |
|---|---|---|
| body | User オブジェクト | (必須) 作成する User オブジェクト。 |
リストを使用したユーザーリストの作成
指定された入力リストを使用してユーザーのリストを作成します。
エンドポイント: https://petstore3.swagger.io/api/v3/user/createWithList
操作: POST
例
- API キー
- OAuth 2.0
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
}
]
POST "https://petstore3.swagger.io/api/v3/user/createWithList" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>" \
-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
}
パラメータ
リクエスト本文
| 名前 | タイプ | 説明 |
|---|---|---|
| body | User オブジェクトの配列 | (必須) 作成する User オブジェクトのリスト。 |
ログイン
ユーザーをシステムにログインさせます。
エンドポイント: https://petstore3.swagger.io/api/v3/user/login
操作: GET
例
- API キー
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/user/login?username=string&password=string" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"
GET "https://petstore3.swagger.io/api/v3/user/login?username=string&password=string" \
-H "accept: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>"
レスポンス
| コード | 説明 |
|---|---|
| 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
例
- API キー
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/user/logout" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"
GET "https://petstore3.swagger.io/api/v3/user/logout" \
-H "accept: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>"
レスポンス
| コード | 説明 |
|---|---|
| 200 | 操作成功 |
| default | 操作成功 |
レスポンス例
200: 操作成功
{
"message": "Successfully logged out"
}
パラメータ
なし
ユーザー名によるユーザーの取得
ユーザー名でユーザーを取得します。
エンドポイント: https://petstore3.swagger.io/api/v3/user/{username}
操作: GET
例
- API キー
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"
GET "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>"
レスポンス
| コード | 説明 |
|---|---|
| 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
例
- API キー
- OAuth 2.0
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
}'
PUT "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>" \
-d '{
"id": 0,
"username": "user1",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}'
レスポンス
| コード | 説明 |
|---|---|
| 200 | 操作成功 |
| 400 | 指定されたユーザーが無効 |
| 404 | ユーザーが見つかりません |
| default | 予期しないエラー |
(更新が成功した場合、レスポンスボディなしで 200 コードが返されます。)
パラメータ
パスパラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
| username | 文字列 | 更新するユーザーのユーザー名 |
リクエスト本文
| 名前 | タイプ | 説明 |
|---|---|---|
| body | User オブジェクト | (必須) 更新された情報を含む User オブジェクト。 |
ユーザーの削除
ユーザーを削除します。
エンドポイント: https://petstore3.swagger.io/api/v3/user/{username}
操作: DELETE
例
- API キー
- OAuth 2.0
DELETE "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"
DELETE "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "Authorization: Bearer <YOUR_OAUTH_TOKEN>"
レスポンス
| コード | 説明 |
|---|---|
| 200 | ユーザーが削除されました |
| 400 | 指定されたユーザー名が無効 |
| 404 | ユーザーが見つかりません |
(削除が成功した場合、レスポンスボディなしで 200 コードが返されます。)
パラメータ
パスパラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
| username | 文字列 | 削除するユーザーのユーザー名 |