ujusum:1-projet:6-spec-open-api
Table des matières
Spécification OpenAPI 3.1
Objectif
Cette spécification constitue le contrat officiel entre :
- Frontend NextJS
- Backend NestJS
- Applications mobiles futures
- SDK partenaires
- Intégrations externes
Elle permet :
- Génération Swagger
- Génération SDK TypeScript
- Génération SDK Java
- Génération SDK PHP
- Génération SDK Flutter
- Génération automatique des DTO
Convention API
Base URL
https://api.location-platform.com/api/v1
Format
application/json
Encodage
UTF-8
Versionning
/api/v1 /api/v2
Authentification
JWT
Header obligatoire :
Authorization: Bearer <access_token>
Schéma OpenAPI
components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT
Structure des réponses
Succès
{
"success": true,
"data": {},
"meta": {},
"links": {}
}
Erreur
{
"success": false,
"error": {
"code": "PROPERTY_NOT_FOUND",
"message": "Property not found"
}
}
Pagination
Paramètres
?page=1 ?pageSize=20
Réponse
{
"success": true,
"data": [],
"meta": {
"page": 1,
"pageSize": 20,
"total": 245,
"pages": 13
}
}
Tri
Paramètres
?sort=createdAt ?sort=-createdAt ?sort=price ?sort=-price
Filtrage
Exemple
GET /properties ?city=Montpellier &status=PUBLISHED &minPrice=100 &maxPrice=300
DTO Standards
UUID
Uuid: type: string format: uuid
Money
Money: type: number format: double
Date
Date: type: string format: date
DateTime
DateTime: type: string format: date-time
Module Auth
Login
Request
POST /auth/login
Body :
{
"email": "john@example.com",
"password": "secret"
}
Response
{
"success": true,
"data": {
"accessToken": "...",
"refreshToken": "...",
"expiresIn": 3600
}
}
Register
POST /auth/register
Refresh Token
POST /auth/refresh
Logout
POST /auth/logout
Module Users
User DTO
User: type: object properties: id: $ref: '#/components/schemas/Uuid' email: type: string status: type: string profile: $ref: '#/components/schemas/UserProfile'
UserProfile DTO
UserProfile: type: object properties: firstName: type: string lastName: type: string phone: type: string
Endpoints
GET /users/me
PUT /users/me
GET /users/{id}
GET /users
DELETE /users/{id}
Module Properties
Property DTO
Property: type: object properties: id: type: string code: type: string title: type: string status: type: string surface: type: number roomCount: type: integer bedroomCount: type: integer bathroomCount: type: integer capacity: type: integer address: $ref: '#/components/schemas/PropertyAddress'
PropertyAddress DTO
PropertyAddress: type: object properties: address1: type: string city: type: string postalCode: type: string country: type: string latitude: type: number longitude: type: number
Recherche de biens
GET /properties
Paramètres :
city status minPrice maxPrice bedrooms bathrooms capacity page pageSize sort
Création
POST /properties
Consultation
GET /properties/{id}
Modification
PUT /properties/{id}
Suppression
DELETE /properties/{id}
Module Reservations
Reservation DTO
Reservation: type: object properties: id: type: string reservationNumber: type: string status: type: string startDate: type: string endDate: type: string totalAmount: type: number
Création réservation
POST /reservations
Body :
{
"propertyId": "uuid",
"startDate": "2026-07-01",
"endDate": "2026-07-15",
"guestCount": 4
}
Consultation
GET /reservations/{id}
Modification
PUT /reservations/{id}
Annulation
POST /reservations/{id}/cancel
Module Contracts
Contract DTO
Contract: type: object properties: id: type: string contractNumber: type: string status: type: string signedAt: type: string
Génération
POST /contracts/generate
Signature
POST /contracts/{id}/sign
Téléchargement
GET /contracts/{id}/download
Module Payments
Payment DTO
Payment: type: object properties: id: type: string amount: type: number status: type: string paymentDate: type: string
Paiement
POST /payments
Historique
GET /payments
GET /payments/{id}
Remboursement
POST /payments/{id}/refund
Module CRM
Leads
GET /crm/leads
POST /crm/leads
PUT /crm/leads/{id}
DELETE /crm/leads/{id}
Activités
GET /crm/activities POST /crm/activities
Module Messaging
Conversations
GET /conversations
POST /conversations
GET /conversations/{id}
Messages
GET /conversations/{id}/messages
POST /conversations/{id}/messages
Module Reporting
Dashboard
GET /reports/dashboard
KPI
GET /reports/kpis
Export
POST /reports/export
Validation métier
Property
title: minLength: 5 maxLength: 255 surface: minimum: 1 capacity: minimum: 1
Reservation
startDate: required: true endDate: required: true guestCount: minimum: 1
Payment
amount: minimum: 0.01
Codes erreurs
| Code | HTTP | Description |
|---|---|---|
| VALIDATION_ERROR | 400 | Données invalides |
| UNAUTHORIZED | 401 | Authentification requise |
| FORBIDDEN | 403 | Accès refusé |
| NOT_FOUND | 404 | Ressource inexistante |
| CONFLICT | 409 | Conflit métier |
| INTERNAL_ERROR | 500 | Erreur serveur |
Swagger
Configuration NestJS
const config =
new DocumentBuilder()
.setTitle('Rental API')
.setDescription('Rental Platform API')
.setVersion('1.0')
.addBearerAuth()
.build();
URL Swagger
https://api.location-platform.com/docs
Volume estimé
| Domaine | Endpoints |
|---|---|
| Auth | 15 |
| Users | 20 |
| Owners | 20 |
| Properties | 40 |
| Reservations | 35 |
| Contracts | 15 |
| Payments | 20 |
| CRM | 25 |
| Messaging | 15 |
| Reporting | 20 |
| Administration | 25 |
Total estimé : environ 250 endpoints REST.
Livrables générés
- Contrat OpenAPI 3.1
- Swagger UI
- DTO TypeScript
- SDK Frontend
- SDK Mobile
- Validation JSON Schema
- Documentation API
Étape suivante
À partir de cette spécification OpenAPI, nous pouvons désormais produire :
- Architecture Frontend NextJS 15
- Organisation des pages App Router
- Gestion d'état (TanStack Query)
- Génération automatique du client API
- Design System
- Maquettes détaillées
- Parcours utilisateurs
- Backlog Agile complet
Le prochain livrable recommandé est :
Backlog Agile détaillé (Epics → Features → User Stories → Tasks)
Ce document deviendra la base du pilotage projet et des futurs sprints Scrum.
ujusum/1-projet/6-spec-open-api.txt · Dernière modification : 2026/06/06 02:53 de 91.170.108.99