1
0
forked from PGL/Clyde
Clyde/Documents/proto/general/openapi.yaml
2023-12-08 13:38:42 +01:00

456 lines
11 KiB
YAML

# hihi
openapi: 3.0.0
info:
title: ClydeAPI
description: Clyde's api
version: 0.0.1
servers:
- url: https://clyde.herisson.ovh/api
description: default api point for clyde's service
paths:
/ping:
get:
summary: Vérifie l'état de l'api.
responses:
default:
description: Retourne pong
content:
text/plain:
schema:
type: string
example: pong
/users:
get:
summary: Liste les utilisateurs
tags:
- SI
security:
- bearer: []
parameters:
- in: query
name: type
required: false
schema:
type: string
enum: [teacher, student, secretary]
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/User"
'401':
$ref: '#/components/responses/UnauthorizedError'
/user:
get:
summary: Récupére ses informations
tags:
- Users
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: "#/components/schemas/User"
post:
summary: Créer un utilisateur
tags:
- Users
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
LastName:
type: string
FirstName:
type: string
Email:
type: string
Address:
$ref: "#/components/schemas/Address"
BirthDate:
type: string
description: Follow the iso 8601 ("YYYY-MM-DD")
example:
{
"LastName": "Doe" ,
"FirstName": "John",
"Email": "John.Doe@example.com",
"Address": {
"Address": "Rue de Tounais 42",
"Country": "BE"},
"BirthDate": "1941-02-22",
}
responses:
'201':
description: User created
'401':
$ref: '#/components/responses/UnauthorizedError'
patch:
summary: modifier ses informations
tags:
- Users
security:
- bearer: []
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/User'
responses:
'201':
description: Informations modifiées
'401':
$ref: '#/components/responses/UnauthorizedError'
/user/{mat}:
get:
summary: Récupérer les informations d'un utilisateur
tags:
- Admin
responses:
'200':
description: Utilisateur trouvé
content:
application/json:
schema:
$ref: "#/components/schemas/User"
parameters:
- name: mat
in: path
description: Matricule of the user (unique id)
required: true
schema:
type: integer
patch:
summary: modifier les informations d'un utilisateur
tags:
- Admin
security:
- bearer: []
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/User'
responses:
'201':
description: Informations modifiées
'401':
$ref: '#/components/responses/UnauthorizedError'
/course:
post:
summary: Créer un nouveau cours
tags:
- Courses
- Secretariat
security:
- bearer: []
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
type: string
courses:
type: array
items:
type: string
responses:
'201':
description: Nouveau cours crée
'401':
$ref: '#/components/responses/UnauthorizedError'
/courses/{id}:
get:
summary: Voir les informations sur un cours
tags:
- Courses
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Course'
parameters:
- name: id
in: path
required: true
schema:
type: integer
delete:
summary: Suprimer un cours
tags:
- Courses
- Secretariat
security:
- bearer: []
responses:
'201':
description: Success
'401':
$ref: '#/components/responses/UnauthorizedError'
patch:
summary: Changer les options du cours
tags:
- Secretariat
- Courses
security:
- bearer: []
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
type: string
credits:
type: integer
faculty:
type: string
teachers:
type: object
$ref: '#/components/schemas/User'
assistants:
type: array
items:
$ref: '#/components/schemas/User'
example:
{
"name": "Math pour l'info",
"credits": 11,
"faculty": "science",
"Teacher": ,
"Assistants": [ ]
}
responses:
'201':
description: Cours modifié
'401':
$ref: '#/components/responses/UnauthorizedError'
/cursus:
post:
summary: Créer un nouveau cursus
tags:
- cursus
security:
- bearer: []
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
type: string
credits:
type: integer
faculty:
type: string
teachers:
type: object
$ref: '#/components/schemas/User'
assistants:
type: array
items:
$ref: '#/components/schemas/User'
example:
{
"name": "Math pour l'info",
"credits": 11,
"faculty": "science",
"Teacher": ,
"Assistants": [ ]
}
responses:
'201':
description: Nouveau cursus crée
'401':
$ref: '#/components/responses/UnauthorizedError'
/cursus/{id}:
get:
summary: Voir les informations sur un cursus
tags:
- cursus
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Cursus'
parameters:
- name: id
in: path
required: true
schema:
type: integer
delete:
summary: Suprimer un cursus
tags:
- cursus
security:
- bearer: []
responses:
'201':
description: Success
'401':
$ref: '#/components/responses/UnauthorizedError'
patch:
summary: Changer les options du cursus
tags:
- cursus
security:
- bearer: []
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
type: string
credits:
type: integer
faculty:
type: string
teachers:
type: object
$ref: '#/components/schemas/User'
assistants:
type: array
items:
$ref: '#/components/schemas/User'
example:
{
"name": "Math pour l'info",
"credits": 11,
"faculty": "science",
"Teacher": ,
"Assistants": [ ]
}
responses:
'201':
description: Cours modifié
'401':
$ref: '#/components/responses/UnauthorizedError'
components:
securitySchemes:
bearer:
type: http
scheme: bearer
schemas:
User:
type: object
properties:
regNo:
type: integer
photo:
type: object
lastName:
type: string
firstName:
type: string
email:
type: string
address:
$ref: "#/components/schemas/Address"
birthDate:
type: string
description: Follow the iso 8601 ("YYYY-MM-DD")
example:
{
"regNo": 42,
"lastName": "Doe" ,
"firstName": "John",
"email": "John.Doe@example.com",
"address": {
"address": "Rue de Tounais 42",
"country": "BE"},
"birthDate": "1941-02-22",
"staffMember": true,
}
Address:
type: object
properties:
address:
type: string
country:
type: string
description: Follow the ISO-3166-1 alpha-2 standard.
example:
{
"address": "Rue de Tounais 42",
"country": "BE"
}
Course:
type: object
properties:
id:
type: integer
name:
type: string
credits:
type: integer
faculty:
type: string
teachers:
type: object
$ref: '#/components/schemas/User'
assistants:
type: array
items:
$ref: '#/components/schemas/User'
example:
{
"id": 42,
"name": "Math pour l'info",
"credits": 11,
"faculty": "science",
"Teacher": ,
"Assistants": [ ]
}
Cursus:
type: object
properties:
id:
type: integer
name:
type: string
courses:
type: array
items:
type: string
example:
{
"id": 42,
"courses": ['Math', 'Info']
}
responses:
UnauthorizedError:
description: Permission non accordée