added swagger doc
This commit is contained in:
281
laravel/openapi-swagger.yml
Normal file
281
laravel/openapi-swagger.yml
Normal file
@@ -0,0 +1,281 @@
|
||||
openapi: 3.0.4
|
||||
info:
|
||||
title: Blog API
|
||||
description: |-
|
||||
Projet Laravel avec Sanctum pour l'authentification
|
||||
license:
|
||||
name: Creative Commons 4.0
|
||||
url: https://creativecommons.org/licenses/by/4.0/
|
||||
version: 1.0.0
|
||||
servers:
|
||||
- url: https://isi2.ale-pri.com/api/
|
||||
description: Serveur de production
|
||||
- url: http://localhost:8000/api/
|
||||
description: Serveur de développement local
|
||||
tags:
|
||||
- name: billets
|
||||
description: Opérations sur les billets
|
||||
- name: commentaires
|
||||
description: Operations sur les commentaires
|
||||
- name: user
|
||||
description: Operations about user
|
||||
paths:
|
||||
/billets:
|
||||
get:
|
||||
tags:
|
||||
- billets
|
||||
summary: Liste des billets
|
||||
operationId: getBillets
|
||||
responses:
|
||||
'200':
|
||||
description: Liste des billets
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Billet'
|
||||
/login:
|
||||
post:
|
||||
responses:
|
||||
'200':
|
||||
description: Authentification réussie
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TokenResponse'
|
||||
'401':
|
||||
description: Authentification échouée
|
||||
tags:
|
||||
- user
|
||||
summary: Authentification de l'utilisateur
|
||||
operationId: loginUser
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LoginRequest'
|
||||
/register:
|
||||
post:
|
||||
responses:
|
||||
'201':
|
||||
description: Utilisateur créé avec succès
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TokenResponse'
|
||||
'422':
|
||||
description: Erreur de validation
|
||||
tags:
|
||||
- user
|
||||
summary: Enregistrement d'un nouvel utilisateur
|
||||
operationId: registerUser
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/RegisterRequest'
|
||||
/user:
|
||||
get:
|
||||
security:
|
||||
- sanctum: []
|
||||
tags:
|
||||
- user
|
||||
summary: Récupérer les informations de l'utilisateur connecté
|
||||
operationId: getUser
|
||||
responses:
|
||||
'200':
|
||||
description: Informations de l'utilisateur
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
'401':
|
||||
description: Non autorisé
|
||||
/user/logout:
|
||||
post:
|
||||
security:
|
||||
- sanctum: []
|
||||
tags:
|
||||
- user
|
||||
summary: Déconnexion de l'utilisateur
|
||||
operationId: logoutUser
|
||||
responses:
|
||||
'204':
|
||||
description: Déconnexion réussie
|
||||
'401':
|
||||
description: Non autorisé
|
||||
/billets/{id}:
|
||||
get:
|
||||
security:
|
||||
- sanctum: []
|
||||
tags:
|
||||
- billets
|
||||
summary: Détails d'un billet
|
||||
operationId: getBilletById
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
description: ID du billet
|
||||
responses:
|
||||
'200':
|
||||
description: Détails du billet
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BilletWithComments'
|
||||
'404':
|
||||
description: Billet non trouvé
|
||||
/commentaires:
|
||||
post:
|
||||
security:
|
||||
- sanctum: []
|
||||
tags:
|
||||
- commentaires
|
||||
summary: Ajouter un commentaire à un billet
|
||||
operationId: addComment
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CommentaireRequest'
|
||||
responses:
|
||||
'201':
|
||||
description: Commentaire ajouté avec succès
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Commentaire'
|
||||
'422':
|
||||
description: Erreur de validation
|
||||
|
||||
|
||||
components:
|
||||
schemas:
|
||||
Billet:
|
||||
type: object
|
||||
properties:
|
||||
Date:
|
||||
type: string
|
||||
format: date-time
|
||||
example: '2023-10-01'
|
||||
Titre:
|
||||
type: string
|
||||
example: Billet 1
|
||||
Contenu:
|
||||
type: string
|
||||
example: Lorem ipsum dolor sit amet.
|
||||
BilletWithComments:
|
||||
type: object
|
||||
properties:
|
||||
Date:
|
||||
type: string
|
||||
format: date-time
|
||||
example: '2023-10-01'
|
||||
Titre:
|
||||
type: string
|
||||
example: Billet 1
|
||||
Contenu:
|
||||
type: string
|
||||
example: Lorem ipsum dolor sit amet.
|
||||
Commentaires:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Commentaire'
|
||||
Commentaire:
|
||||
type: object
|
||||
properties:
|
||||
COM_DATE:
|
||||
type: string
|
||||
format: date-time
|
||||
example: '2023-10-01'
|
||||
COM_AUTEUR:
|
||||
type: string
|
||||
example: John Doe
|
||||
COM_CONTENU:
|
||||
type: string
|
||||
example: Lorem ipsum dolor sit amet.
|
||||
billet_id:
|
||||
type: integer
|
||||
example: 1
|
||||
user_id:
|
||||
type: integer
|
||||
example: 1
|
||||
CommentaireRequest:
|
||||
type: object
|
||||
properties:
|
||||
COM_DATE:
|
||||
type: string
|
||||
format: date-time
|
||||
example: '2023-10-01'
|
||||
COM_CONTENU:
|
||||
type: string
|
||||
example: Lorem ipsum dolor sit amet.
|
||||
billet_id:
|
||||
type: integer
|
||||
example: 1
|
||||
user_id:
|
||||
type: integer
|
||||
example: 1
|
||||
LoginRequest:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
example: au@secou.rs
|
||||
password:
|
||||
type: string
|
||||
format: password
|
||||
example: secret123
|
||||
TokenResponse:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
example: 1|a2b3c4d5e6f7g8h9i0j
|
||||
type:
|
||||
type: string
|
||||
example: Bearer
|
||||
RegisterRequest:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: John Doe
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
example: au@secou.rs
|
||||
password:
|
||||
type: string
|
||||
format: password
|
||||
example: secret123
|
||||
User:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
example: 1
|
||||
name:
|
||||
type: string
|
||||
example: John Doe
|
||||
email:
|
||||
type: string
|
||||
format: email
|
||||
example: au@secou.rs
|
||||
securitySchemes:
|
||||
sanctum:
|
||||
type: http
|
||||
scheme: bearer
|
||||
bearerFormat: Bearer
|
||||
description: Utiliser le token Bearer pour l'authentification
|
||||
Reference in New Issue
Block a user