Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jugurtha/ajout du swagger #516

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
665 changes: 665 additions & 0 deletions lib/api/address/routes.js

Large diffs are not rendered by default.

87 changes: 87 additions & 0 deletions lib/api/ban-id/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,93 @@ import {getUuids, uncollidUuids} from './helpers.js'

const app = new express.Router()

/**
* @swagger
* /api/ban-id:
* get:
* summary: Générer des UUID uniques
* description: Permet de générer un nombre spécifié d'UUID uniques, avec une limite maximale de 100 000 UUID.
* tags:
* - UUID Generator
* parameters:
* - in: query
* name: quantity
* schema:
* type: integer
* example: 5
* default: 1
* minimum: 1
* maximum: 100000
* description: The number of UUIDs to generate.
* responses:
* 200:
* description: A list of generated UUIDs.
* content:
* application/json:
* schema:
* type: object
* properties:
* date:
* type: string
* format: date-time
* description: The date and time of the response.
* status:
* type: string
* example: success
* description: The response status (success or error).
* response:
* type: array
* items:
* type: string
* description: List of generated UUIDs.
* 400:
* description: Invalid query parameters.
* content:
* application/json:
* schema:
* type: object
* properties:
* date:
* type: string
* format: date-time
* description: The date and time of the response.
* status:
* type: string
* example: error
* description: The response status (success or error).
* message:
* type: string
* example: Quantity must be less than 100 000.
* description: Error description.
* response:
* type: object
* example: {}
* description: Response content (empty in case of error).
* 500:
* description: Internal server error.
* content:
* application/json:
* schema:
* type: object
* properties:
* date:
* type: string
* format: date-time
* description: The date and time of the response.
* status:
* type: string
* example: error
* description: The response status (success or error).
* message:
* type: string
* example: An internal error occurred.
* description: Error message.
* response:
* type: object
* example: {}
* description: Response content (empty in case of error).
*/

app.get('/', analyticsMiddleware, async (req, res) => {
try {
const length = Number(req.query.quantity) || 1
Expand Down
132 changes: 132 additions & 0 deletions lib/api/certificate/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,63 @@ import {formatDataForCertificate} from './utils.js'
const app = new express.Router()
app.use(express.json())

/**
* @swagger
* tags:
* name: Certificat
* description: API de gestion des certificats
*/

/**
* @swagger
* /api/certificate/{id}:
* get:
* summary: Récupérer un certificat par ID
* description: Permet de récupérer le certificat associé à l'ID fourni.
* tags:
* - Certificat
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: string
* description: Identifiant unique du certificat à récupérer.
* example: "abc123"
* responses:
* 200:
* description: The requested certificate.
* content:
* application/json:
* schema:
* type: object
* properties:
* id:
* type: string
* data:
* type: object
* 404:
* description: Certificate not found.
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: Certificate not found
* 500:
* description: Internal server error.
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: Internal server error
*/

app.get('/:id', async (req, res) => {
const {id} = req.params
try {
Expand All @@ -28,6 +85,81 @@ app.get('/:id', async (req, res) => {
}
})

/**
* @swagger
* /api/certificate/:
* post:
* summary: Créer un nouveau certificat
* description: Génère un certificat pour l'ID d'adresse fourni, si tous les critères sont remplis. Requiert une authentification.
* tags:
* - Certificat
* security:
* - bearerAuth: [] # Secured with Bearer token
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* addressID:
* type: string
* description: Identifiant unique de l'adresse à certifier.
* example: "12345"
* responses:
* 201:
* description: The newly created certificate.
* content:
* application/json:
* schema:
* type: object
* properties:
* id:
* type: string
* data:
* type: object
* 400:
* description: Invalid input or address configuration issue.
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: Address is not certified, active, or has no parcels.
* 401:
* description: Unauthorized.
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: Authentication required.
* 403:
* description: Forbidden. Insufficient permissions.
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: User does not have permission to create a certificate.
* 500:
* description: Internal server error.
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* example: Internal server error
*/

app.post('/', auth, async (req, res) => {
try {
const {addressID} = req.body
Expand Down
Loading
Loading