Fonctions de l'API utilisateur
Cette section décrit les opérations relatives aux utilisateurs.
Création d'un utilisateur
Crée un nouveau compte utilisateur.
Point de terminaison : https://petstore3.swagger.io/api/v3/user
Opération : POST
Exemples
- API Key
- OAuth 2.0
POST "https://petstore3.swagger.io/api/v3/user" \
-H "accept : application/json" \
-H "Content-Type : application/json" \
-H "api_key : <VOTRE_CLÉ_API>" \
-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
}'
Réponses
| Code | Description |
|---|---|
| default | Opération réussie |
Exemple de réponse
200 : opération réussie
{
"id" : 10,
"username" : "theUser",
"firstName" : "John",
"lastName" : "James",
"email" : "john@email.com",
"password" : "12345",
"phone" : "12345",
"userStatus" : 1
}
Paramètres
Corps de la requête
| Nom | Type | Description |
|---|---|---|
| objet | objet utilisateur | (Obligatoire) L'objet Utilisateur à créer. |
Création d'une liste d'utilisateurs avec liste
Crée une liste d'utilisateurs à partir d'une liste donnée.
Point d'arrivée : https://petstore3.swagger.io/api/v3/user/createWithList
Opération : POST
Exemples
Exemples
- API Key
- OAuth 2.0
POST "https://petstore3.swagger.io/api/v3/user/createWithList" \
-H "accept : application/json" \
-H "Content-Type : application/json" \
-H "api_key : <VOTRE_CLÉ_API>" \
-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
}
]
Réponses
| Code | Description |
|---|---|
| default | Opération réussie |
Exemple de réponse
200 : Opération réussie
{
"id" : 0,
"username" : "string",
"firstName" : "string",
"lastName" : "string",
"email" : "string",
"password" : "string",
"phone" : "string",
"userStatus" : 0
}
Paramètres
Corps de la requête
| Nom | Type | Description |
|---|---|---|
| corps | Tableau d'objets Utilisateur | (Obligatoire) La liste des objets Utilisateur à créer. |
Se connecter
Connecte l'utilisateur au système.
Point d'arrivée : https://petstore3.swagger.io/api/v3/user/login
Opération : GET
Exemples
- API Key
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/user/login?username=string&password=string" \
-H "accept : application/json" \
-H "api_key : <VOTRE_CLÉ_API>"
GET "https://petstore3.swagger.io/api/v3/user/login?username=string&password=string" \
-H "accept : application/json" \
-H "Authorization : Bearer <YOUR_OAUTH_TOKEN>"
Réponses
| Code | Description |
|---|---|
| 200 | opération réussie |
| 400 | Nom d'utilisateur/mot de passe non valide fourni |
| par défaut | Erreur inattendue |
Exemple de réponse
200 : opération réussie
{
"message" : "Session utilisateur connectée:abcdef12345"
}
En-têtes:
| Nom | Description | Type |
|---|---|---|
X-Rate-Limit | Appels par heure autorisés par l'utilisateur. | entier |
X-Expires-After | Date en UTC à laquelle le jeton expire. | chaîne de caractères |
Paramètres
Paramètres de la requête
| Nom | Type | Description |
|---|---|---|
| nom d'utilisateur | chaîne de caractères | Le nom d'utilisateur pour la connexion. |
| mot de passe | chaîne | Le mot de passe pour la connexion en clair. |
Se déconnecter
Déconnecte la session utilisateur actuellement connectée.
Point de terminaison : https://petstore3.swagger.io/api/v3/user/logout
Opération : GET
Exemples
- API Key
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/user/logout" \
-H "accept : application/json" \
-H "api_key : <VOTRE_CLÉ_API>"
GET "https://petstore3.swagger.io/api/v3/user/logout" \
-H "accept : application/json" \
-H "Authorization : Bearer <YOUR_OAUTH_TOKEN>"
Réponses
| Code | Description |
|---|---|
| 200 | opération réussie |
| par défaut | opération réussie |
Exemple de réponse
200 : opération réussie
{
"message" : "Déconnexion réussie"
}
Paramètres
Aucun
Obtenir un utilisateur par son nom d'utilisateur
Obtient un utilisateur à l'aide de son nom d'utilisateur.
Point de terminaison : https://petstore3.swagger.io/api/v3/user/{username}
Opération : GET
Exemples
- API Key
- OAuth 2.0
GET "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept : application/json" \
-H "api_key : <VOTRE_CLÉ_API>"
GET "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept : application/json" \
-H "Authorization : Bearer <YOUR_OAUTH_TOKEN>"
Réponses
| Code | Description |
|---|---|
| 200 | opération réussie |
| 400 | Nom d'utilisateur invalide fourni |
| 404 | Utilisateur non trouvé |
| par défaut | Erreur inattendue |
200 : opération réussie
{
"id" : 0,
"username" : "string",
"firstName" : "string",
"lastName" : "string",
"email" : "string",
"password" : "string",
"phone" : "string",
"userStatus" : 0
}
Paramètres
Paramètres du chemin d'accès
| Nom | Type | Description |
|---|---|---|
| nom d'utilisateur | chaîne de caractères | Le nom d'utilisateur de l'utilisateur à récupérer. Utilisez "user" pour les tests. |
Mise à jour d'un utilisateur
Met à jour un utilisateur.
Point de terminaison : https://petstore3.swagger.io/api/v3/user/{username}
Opération : PUT
Exemples
- API Key
- OAuth 2.0
PUT "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept : application/json" \
-H "Content-Type : application/json" \
-H "api_key : <VOTRE_CLÉ_API>" \
-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
}'
Réponses
| Code | Description |
|---|---|
| 200 | Opération réussie |
| 400 | Utilisateur invalide fourni |
| 404 | Utilisateur non trouvé |
| par défaut | Erreur inattendue |
(Une mise à jour réussie renvoie un code 200 sans corps de réponse).
Paramètres
Paramètres du chemin d'accès
| Nom | Type | Description |
|---|---|---|
| username | string | Le nom d'utilisateur de l'utilisateur à mettre à jour |
Corps de la requête
| Nom | Type | Description |
|---|---|---|
| corps | Objet utilisateur | (Requis) L'objet User avec les informations mises à jour. |
Suppression d'un utilisateur
Supprime un utilisateur.
Point de terminaison : https://petstore3.swagger.io/api/v3/user/{username}
Opération : DELETE
Exemples
- API Key
- OAuth 2.0
DELETE "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept : application/json" \
-H "api_key : <VOTRE_CLÉ_API>"
DELETE "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept : application/json" \
-H "Authorization : Bearer <YOUR_OAUTH_TOKEN>"
Réponses
| Code | Description |
|---|---|
| 200 | Utilisateur supprimé |
| 400 | Nom d'utilisateur invalide fourni |
| 404 | Utilisateur non trouvé |
(Une suppression réussie renvoie un code 200 sans corps de réponse).
Paramètres
Paramètres du chemin d'accès
| Nom | Type | Description |
|---|---|---|
| username | string | Le nom de l'utilisateur à supprimer |