API exemple avec collection MongoDB étudiants
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

324 lines
6.6 KiB

{
"swagger": "2.0",
"info": {
"description": "Bienvenue pour tester ma nouvelle api de sauvegarde des etudiants. http://localhost:3000 <br> Pour voir la collection etudiant aller à http://localhost:3000/api/etudiants",
"version": "1.0.0",
"title": "Documentation API - Etudiants",
"contact": {
"email": "art-dambrine@live.fr"
}
},
"host": "localhost:3000",
"basePath": "/api",
"tags": [
{
"name": "etudiant",
"description": "Everything about your etudiants"
}
],
"schemes": [
"http"
],
"paths": {
"/etudiants": {
"get": {
"tags": [
"etudiant"
],
"summary": "Retourne la collection d'etudiants",
"description": "Retourne l'ensemble des etudiants",
"operationId": "getetudiants",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/etudiant"
}
},
"404": {
"description": "etudiants not found"
}
}
},
"post": {
"tags": [
"etudiant"
],
"summary": "Ajoute un nouvel etudiant à la collection",
"description": "",
"operationId": "addetudiant",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "etudiant object that needs to be added to the store",
"required": true,
"schema": {
"$ref": "#/definitions/etudiant"
}
}
],
"responses": {
"405": {
"description": "Invalid input"
}
}
}
},
"/etudiants/{etudiantId}": {
"get": {
"tags": [
"etudiant"
],
"summary": "Retrouve un etudiant par ID",
"description": "Retourne un seul etudiant",
"operationId": "getetudiantById",
"produces": [
"application/json"
],
"parameters": [
{
"name": "etudiantId",
"in": "path",
"description": "ID of etudiant to return",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/etudiant"
}
},
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "etudiant not found"
}
}
},
"put": {
"tags": [
"etudiant"
],
"summary": "Update un etudiant dans la collection avec les données du formulaire",
"description": "",
"operationId": "updateetudiantWithForm",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "etudiantId",
"in": "path",
"description": "ID de l'etudiant qui doit être update",
"required": true,
"type": "string"
},
{
"name": "numEtudiant",
"in": "formData",
"description": "Updated name of the etudiant",
"required": true,
"type": "string"
},
{
"name": "firstname",
"in": "formData",
"description": "Updated status of the etudiant",
"required": true,
"type": "string"
},
{
"name": "lastname",
"in": "formData",
"description": "Updated status of the etudiant",
"required": true,
"type": "string"
},
{
"name": "cycle",
"in": "formData",
"description": "Updated status of the etudiant",
"required": true,
"type": "number"
},
{
"name": "adresse",
"in": "formData",
"description": "Updated status of the etudiant",
"required": false,
"type": "object",
"properties":{
"num": {
"type": "number"
},
"rue": {
"type": "string"
},
"ville": {
"type": "string"
},
"pays": {
"type": "string"
}
}
},
{
"name": "email",
"in": "formData",
"description": "Updated status of the etudiant",
"required": false,
"type": "array",
"items": {
"type": "string"
}
},
{
"name": "cours",
"in": "formData",
"description": "Updated status of the etudiant",
"required": false,
"type": "array",
"items": {
"type": "object",
"properties":{
"code": {
"type": "string"
},
"titre": {
"type": "string"
},
"description": {
"type": "string"
},
"credit": {
"type": "number"
}
}
}
}
],
"responses": {
"405": {
"description": "Invalid input"
}
}
},
"delete": {
"tags": [
"etudiant"
],
"summary": "Supprime un etudiant",
"description": "",
"operationId": "deleteetudiant",
"produces": [
"application/json"
],
"parameters": [
{
"name": "etudiantId",
"in": "path",
"description": "etudiant id to delete",
"required": true,
"type": "string"
}
],
"responses": {
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "etudiant not found"
}
}
}
}
},
"definitions": {
"etudiant": {
"type": "object",
"required": [
"numEtudiant",
"firstname",
"lastname",
"cycle"
],
"properties": {
"numEtudiant": {
"type": "string",
"example": "etu2020001"
},
"firstname": {
"type": "string",
"example": "Arthur"
},
"lastname": {
"type": "string",
"example": "Morgan"
},
"cycle": {
"type": "number"
},
"adresse": {
"type": "object",
"properties":{
"num": {
"type": "number"
},
"rue": {
"type": "string"
},
"ville": {
"type": "string"
},
"pays": {
"type": "string"
}
}
},
"email": {
"type": "array",
"items": {
"type": "string"
}
},
"cours": {
"type": "array",
"items": {
"type": "object",
"properties":{
"code": {
"type": "string"
},
"titre": {
"type": "string"
},
"description": {
"type": "string"
},
"credit": {
"type": "number"
}
}
}
}
}
}
}
}