diff --git a/.vs/MyCore/v15/Server/sqlite3/storage.ide b/.vs/MyCore/v15/Server/sqlite3/storage.ide index f3798b7..cc7bf33 100644 Binary files a/.vs/MyCore/v15/Server/sqlite3/storage.ide and b/.vs/MyCore/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/MyCore/v15/Server/sqlite3/storage.ide-wal b/.vs/MyCore/v15/Server/sqlite3/storage.ide-wal index 9348df4..d51bfdc 100644 Binary files a/.vs/MyCore/v15/Server/sqlite3/storage.ide-wal and b/.vs/MyCore/v15/Server/sqlite3/storage.ide-wal differ diff --git a/MyCore/Controllers/DeviceController.cs b/MyCore/Controllers/DeviceController.cs index e05d5f6..85a4916 100644 --- a/MyCore/Controllers/DeviceController.cs +++ b/MyCore/Controllers/DeviceController.cs @@ -49,7 +49,7 @@ namespace MyCore.Controllers /// /// /// - [HttpPost("{idDevice}")] + [HttpPost] public IActionResult CreateDevice(int idDevice, [FromBody] Device device) { if (idDevice == 0) diff --git a/MyCore/Controllers/TokenController.cs b/MyCore/Controllers/TokenController.cs index e4fe458..6783a11 100644 --- a/MyCore/Controllers/TokenController.cs +++ b/MyCore/Controllers/TokenController.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; using MyCore.Models; +using MyCore.Services; namespace MyCore.Controllers { @@ -19,73 +20,37 @@ namespace MyCore.Controllers [ApiController] public class TokenController : ControllerBase { + private TokenService _tokenService; + private UserService _userService; + + public TokenController(TokenService tokenService, UserService userService) + { + _tokenService = tokenService; + _userService = userService; + } [AllowAnonymous] [HttpPost] - public ActionResult Create(string username, string password) + public ActionResult Create(string email, string password) { - var test = GenerateSHA256String(password); + //string test = _TokenService.GenerateSHA256String(password); - if (IsValidUserAndPasswordCombination(username, password)) + if (IsValidUserAndPasswordCombination(email, password)) { - UserInfo user = new UserInfo(); - user.FirstName = "Thomas"; - user.LastName = "Fransolet"; - user.Token = GenerateToken(username).ToString(); + UserInfo user = _userService.GetUser(email); + user.Token = _tokenService.GenerateToken(email).ToString(); return user; } - //return new ObjectResult("{\"Token\":\""+GenerateToken(username)+"\"}"); return BadRequest(); } - private object GenerateToken(string username) + private bool IsValidUserAndPasswordCombination(string email, string password) { - var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("%G2YZ=\tgN7fC9M$FXDt#q*a&]Z")); // Put the secret in a file or something - - var claims = new Claim[] { - new Claim(ClaimTypes.Name, username), - new Claim(JwtRegisteredClaimNames.Email, "john.doe@blinkingcaret.com"), - new Claim(ClaimTypes.Role, "Admin") - }; - - var token = new JwtSecurityToken( - issuer: "MyCore App", - audience: "Miotecher", - claims: claims, - notBefore: DateTime.Now, - expires: DateTime.Now.AddDays(28), - signingCredentials: new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256) - ); - - string jwtToken = new JwtSecurityTokenHandler().WriteToken(token); - - return jwtToken; - } - - private bool IsValidUserAndPasswordCombination(string username, string password) - { - if (username == "Thomas" && password == "MonsieurMagic") { return true; } + // Test if is database and is correct + if (email == "thomas.fransolet@hotmail.be" && password == "MonsieurMagic") { return true; } else return false; } - public static string GenerateSHA256String(string inputString) - { - SHA256 sha256 = SHA256Managed.Create(); - byte[] bytes = Encoding.UTF8.GetBytes(inputString); - byte[] hash = sha256.ComputeHash(bytes); - return GetStringFromHash(hash); - } - - private static string GetStringFromHash(byte[] hash) - { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < hash.Length; i++) - { - result.Append(hash[i].ToString("X2")); - } - return result.ToString(); - } - } -} \ No newline at end of file +} diff --git a/MyCore/Controllers/UserController.cs b/MyCore/Controllers/UserController.cs index 2626746..9dc82b9 100644 --- a/MyCore/Controllers/UserController.cs +++ b/MyCore/Controllers/UserController.cs @@ -17,11 +17,13 @@ namespace MyCore.Controllers [ApiController] public class UserController : ControllerBase { - private readonly UserService _userService; + private UserService _userService; + private TokenService _tokenService; - public UserController(UserService userService) + public UserController(UserService userService, TokenService tokenService) { _userService = userService; + _tokenService = tokenService; } // GET api/user @@ -52,6 +54,25 @@ namespace MyCore.Controllers //return _userService.GetUser(id); } + + // POST: User/Create + /// + /// + /// + [AllowAnonymous] + [HttpPost] + public ActionResult CreateUser([FromBody] UserInfo newUser) + { + if (newUser != null) + { + newUser.Token = _tokenService.GenerateToken(newUser.Email).ToString(); + UserInfo userCreated = _userService.CreateUser(newUser); + + return userCreated; + } + return StatusCode(500); + } + /* // POST api/values [HttpPost] diff --git a/MyCore/Models/UserInfo.cs b/MyCore/Models/UserInfo.cs index 26b4974..f61dc4d 100644 --- a/MyCore/Models/UserInfo.cs +++ b/MyCore/Models/UserInfo.cs @@ -54,10 +54,10 @@ namespace MyCore.Models public int PostalCode { get; set; } [BsonElement("ScreenConfigurationIds")] - public int[] ScreenConfigurationIds { get; set; } + public ScreenConfiguration[] ScreenConfigurationIds { get; set; } [BsonElement("DeviceIds")] - public int[] DeviceIds { get; set; } + public Device[] DeviceIds { get; set; } } } diff --git a/MyCore/MyCore.csproj b/MyCore/MyCore.csproj index 2a5b847..27ff158 100644 --- a/MyCore/MyCore.csproj +++ b/MyCore/MyCore.csproj @@ -12,6 +12,7 @@ + diff --git a/MyCore/Services/TokenService.cs b/MyCore/Services/TokenService.cs new file mode 100644 index 0000000..ace3288 --- /dev/null +++ b/MyCore/Services/TokenService.cs @@ -0,0 +1,57 @@ +using Microsoft.IdentityModel.Tokens; +using System; +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Security.Claims; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace MyCore.Services +{ + public class TokenService + { + public object GenerateToken(string username) + { + var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("%G2YZ=\tgN7fC9M$FXDt#q*a&]Z")); // Put the secret in a file or something + + var claims = new Claim[] { + new Claim(ClaimTypes.Name, username), + new Claim(JwtRegisteredClaimNames.Email, "john.doe@blinkingcaret.com"), + new Claim(ClaimTypes.Role, "Admin") + }; + + var token = new JwtSecurityToken( + issuer: "MyCore App", + audience: "Miotecher", + claims: claims, + notBefore: DateTime.Now, + expires: DateTime.Now.AddDays(28), + signingCredentials: new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256) + ); + + string jwtToken = new JwtSecurityTokenHandler().WriteToken(token); + + return jwtToken; + } + + public static string GenerateSHA256String(string inputString) + { + SHA256 sha256 = SHA256Managed.Create(); + byte[] bytes = Encoding.UTF8.GetBytes(inputString); + byte[] hash = sha256.ComputeHash(bytes); + return GetStringFromHash(hash); + } + + public static string GetStringFromHash(byte[] hash) + { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < hash.Length; i++) + { + result.Append(hash[i].ToString("X2")); + } + return result.ToString(); + } + } +} diff --git a/MyCore/Services/UserService.cs b/MyCore/Services/UserService.cs index a283172..1054c15 100644 --- a/MyCore/Services/UserService.cs +++ b/MyCore/Services/UserService.cs @@ -25,9 +25,9 @@ namespace MyCore.Services return _Users.Find(m => true).ToList(); } - public UserInfo GetUser(string id) + public UserInfo GetUser(string email) { - return _Users.Find(m => m.Id == id).FirstOrDefault(); + return _Users.Find(m => m.Email == email).FirstOrDefault(); } public UserInfo CreateUser(UserInfo user) diff --git a/MyCore/Startup.cs b/MyCore/Startup.cs index 169464d..4b6122f 100644 --- a/MyCore/Startup.cs +++ b/MyCore/Startup.cs @@ -35,6 +35,9 @@ namespace MyCore // Add the service (test purpose) services.AddScoped(); services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); @@ -85,7 +88,7 @@ namespace MyCore { app.UseCors( - options => options.WithOrigins("http://localhost:4200").AllowAnyMethod().AllowAnyHeader() + options => options.WithOrigins("http://localhost:4200").AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials() ); // Enable middleware to serve generated Swagger as a JSON endpoint. diff --git a/MyCore/bin/Debug/netcoreapp2.1/MyCore.xml b/MyCore/bin/Debug/netcoreapp2.1/MyCore.xml index 7ed8608..263e26c 100644 --- a/MyCore/bin/Debug/netcoreapp2.1/MyCore.xml +++ b/MyCore/bin/Debug/netcoreapp2.1/MyCore.xml @@ -4,6 +4,33 @@ MyCore + + + + + Id of the device you want to get informatiun + + + + + + Id of the device you want to get information + + + + + + + + + + + + + + + + Retrieve all SmartPrinterMessage @@ -40,6 +67,11 @@ id user + + + + + It's a test ! :) diff --git a/MyCore/obj/Debug/netcoreapp2.1/MyCore.xml b/MyCore/obj/Debug/netcoreapp2.1/MyCore.xml index 7ed8608..263e26c 100644 --- a/MyCore/obj/Debug/netcoreapp2.1/MyCore.xml +++ b/MyCore/obj/Debug/netcoreapp2.1/MyCore.xml @@ -4,6 +4,33 @@ MyCore + + + + + Id of the device you want to get informatiun + + + + + + Id of the device you want to get information + + + + + + + + + + + + + + + + Retrieve all SmartPrinterMessage @@ -40,6 +67,11 @@ id user + + + + + It's a test ! :) diff --git a/swagger.json b/swagger.json index abe177a..72370b0 100644 --- a/swagger.json +++ b/swagger.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"version":"v1","title":"MyCoreApi"},"paths":{"/azure":{"post":{"tags":["Azure"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/AzureADAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/books":{"get":{"tags":["Books"],"operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Book"}}}}},"post":{"tags":["Books"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"book","in":"body","required":false,"schema":{"$ref":"#/definitions/Book"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Book"}}}}},"/api/books/{id}":{"get":{"tags":["Books"],"operationId":"GetBook","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Book"}}}},"put":{"tags":["Books"],"operationId":"Update","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"},{"name":"bookIn","in":"body","required":false,"schema":{"$ref":"#/definitions/Book"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Books"],"operationId":"Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success"}}}},"/facebook":{"post":{"tags":["Facebook"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/FacebookAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/google":{"post":{"tags":["Google"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/GoogleAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/iot/smartprinter/{idDevice}":{"get":{"tags":["IOT"],"summary":"Retrieve all SmartPrinterMessage","operationId":"GetSmartPrinterMessages","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"query","description":"Id of the smart printer message","required":false,"type":"integer","format":"int32"},{"name":"idDevice","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartPrinterMessage"}}}}},"post":{"tags":["IOT"],"summary":"It's the method to post data from mqtt broker to Database (Thanks Rpi!)","operationId":"PostToDBPrinter","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","description":"Id of the device to upload to DB","required":true,"type":"integer","format":"int32"},{"name":"content","in":"body","description":"Content that will be uploaded","required":false,"schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartPrinterMessage"}}}],"responses":{"200":{"description":"Success"},"201":{"description":"Content successfully posted to DB"},"500":{"description":"Unexpected error"}}}},"/api/iot/smartgarden/{idDevice}":{"post":{"tags":["IOT"],"summary":"It's the method to post data from mqtt broker to Database (Thanks Rpi!)","operationId":"PostToDBSmartGarden","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"content","in":"body","required":false,"schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartGardenMessage"}}}],"responses":{"200":{"description":"Success"}}}},"/api/mqtt":{"get":{"tags":["MQTT"],"summary":"It's a mqtt publish test ! :)","operationId":"GetToPublishMqtt","consumes":[],"produces":[],"parameters":[],"responses":{"200":{"description":"Success"}}}},"/api/token":{"post":{"tags":["Token"],"operationId":"Create","consumes":[],"produces":[],"parameters":[{"name":"username","in":"query","required":false,"type":"string"},{"name":"password","in":"query","required":false,"type":"string"}],"responses":{"200":{"description":"Success"}}}},"/token":{"post":{"tags":["Token"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/User"}}],"responses":{"200":{"description":"Success"}}}},"/twitter":{"post":{"tags":["Twitter"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/TwitterAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/user":{"get":{"tags":["User"],"summary":"Get a list of user","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/UserInfo"}}}}}},"/api/user/{id}":{"get":{"tags":["User"],"summary":"Get a specific user","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","description":"id user","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}}},"/api/test":{"get":{"tags":["Values"],"summary":"It's a test ! :)","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"type":"string"}}}}},"post":{"tags":["Values"],"operationId":"Post","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"value","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}}},"/api/test/{id}":{"get":{"tags":["Values"],"operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"Success","schema":{"type":"string"}}}},"put":{"tags":["Values"],"operationId":"Put","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"},{"name":"value","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Values"],"operationId":"Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"Success"}}}}},"definitions":{"AzureADAuthModel":{"type":"object","properties":{"apiKey":{"type":"string"}}},"Book":{"type":"object","properties":{"id":{"type":"string"},"bookName":{"type":"string"},"price":{"format":"double","type":"number"},"category":{"type":"string"},"author":{"type":"string"}}},"FacebookAuthModel":{"type":"object","properties":{"userAccessToken":{"type":"string"}}},"GoogleAuthModel":{"type":"object","properties":{"authorizationCode":{"type":"string"},"apiKey":{"type":"string"}}},"SmartPrinterMessage":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"time":{"type":"string"},"temperature":{"format":"double","type":"number"},"pressure":{"format":"double","type":"number"},"smoke":{"format":"int32","type":"integer"}}},"SmartGardenMessage":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"time":{"type":"string"},"temperature":{"format":"double","type":"number"},"pressure":{"format":"double","type":"number"},"humidity":{"format":"double","type":"number"},"water":{"format":"int32","type":"integer"},"light":{"format":"int32","type":"integer"}}},"User":{"type":"object","properties":{"id":{"type":"string"},"password":{"type":"string"}}},"TwitterAuthModel":{"type":"object","properties":{"apiKey":{"type":"string"}}},"UserInfo":{"type":"object","properties":{"id":{"type":"string"},"role":{"type":"string"},"username":{"type":"string"},"password":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"token":{"type":"string"},"birthday":{"type":"string"}}}},"securityDefinitions":{"Bearer":{"name":"Authorization","in":"header","type":"apiKey","description":"Please enter JWT with Bearer into field"}},"security":[{"Bearer":[]}]} \ No newline at end of file +{"swagger":"2.0","info":{"version":"v1","title":"MyCoreApi"},"paths":{"/azure":{"post":{"tags":["Azure"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/AzureADAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/books":{"get":{"tags":["Books"],"operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Book"}}}}},"post":{"tags":["Books"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"book","in":"body","required":false,"schema":{"$ref":"#/definitions/Book"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Book"}}}}},"/api/books/{id}":{"get":{"tags":["Books"],"operationId":"GetBook","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Book"}}}},"put":{"tags":["Books"],"operationId":"Update","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"},{"name":"bookIn","in":"body","required":false,"schema":{"$ref":"#/definitions/Book"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Books"],"operationId":"Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success"}}}},"/api/device":{"get":{"tags":["Device"],"summary":"","operationId":"GetAllDevices","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Device"}}}}},"post":{"tags":["Device"],"summary":"","operationId":"CreateDevice","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"query","required":false,"type":"integer","format":"int32"},{"name":"device","in":"body","required":false,"schema":{"$ref":"#/definitions/Device"}}],"responses":{"200":{"description":"Success"}}}},"/api/device/{idDevice}":{"get":{"tags":["Device"],"summary":"","operationId":"GetDeviceInfo","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"idDevice","in":"path","description":"Id of the device you want to get information","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/Device"}}}},"put":{"tags":["Device"],"summary":"","operationId":"UpdateDevice","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"device","in":"body","required":false,"schema":{"$ref":"#/definitions/Device"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Device"],"summary":"","operationId":"DeleteDevice","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"deviceId","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}}},"/facebook":{"post":{"tags":["Facebook"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/FacebookAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/google":{"post":{"tags":["Google"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/GoogleAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/iot/smartprinter/{idDevice}":{"get":{"tags":["IOT"],"summary":"Retrieve all SmartPrinterMessage","operationId":"GetSmartPrinterMessages","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"query","description":"Id of the smart printer message","required":false,"type":"integer","format":"int32"},{"name":"idDevice","in":"path","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartPrinterMessage"}}}}},"post":{"tags":["IOT"],"summary":"It's the method to post data from mqtt broker to Database (Thanks Rpi!)","operationId":"PostToDBPrinter","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","description":"Id of the device to upload to DB","required":true,"type":"integer","format":"int32"},{"name":"content","in":"body","description":"Content that will be uploaded","required":false,"schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartPrinterMessage"}}}],"responses":{"200":{"description":"Success"},"201":{"description":"Content successfully posted to DB"},"500":{"description":"Unexpected error"}}}},"/api/iot/smartgarden/{idDevice}":{"post":{"tags":["IOT"],"summary":"It's the method to post data from mqtt broker to Database (Thanks Rpi!)","operationId":"PostToDBSmartGarden","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"idDevice","in":"path","required":true,"type":"integer","format":"int32"},{"name":"content","in":"body","required":false,"schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/SmartGardenMessage"}}}],"responses":{"200":{"description":"Success"}}}},"/api/mqtt":{"get":{"tags":["MQTT"],"summary":"It's a mqtt publish test ! :)","operationId":"GetToPublishMqtt","consumes":[],"produces":[],"parameters":[],"responses":{"200":{"description":"Success"}}}},"/api/token":{"post":{"tags":["Token"],"operationId":"Create","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"email","in":"query","required":false,"type":"string"},{"name":"password","in":"query","required":false,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}}},"/token":{"post":{"tags":["Token"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/User"}}],"responses":{"200":{"description":"Success"}}}},"/twitter":{"post":{"tags":["Twitter"],"operationId":"Create","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["application/json"],"parameters":[{"name":"user","in":"body","required":false,"schema":{"$ref":"#/definitions/TwitterAuthModel"}}],"responses":{"200":{"description":"Success"}}}},"/api/user":{"get":{"tags":["User"],"summary":"Get a list of user","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/UserInfo"}}}}},"post":{"tags":["User"],"summary":"","operationId":"CreateUser","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"newUser","in":"body","required":false,"schema":{"$ref":"#/definitions/UserInfo"}}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}}},"/api/user/{id}":{"get":{"tags":["User"],"summary":"Get a specific user","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","description":"id user","required":true,"type":"string"}],"responses":{"200":{"description":"Success","schema":{"$ref":"#/definitions/UserInfo"}}}}},"/api/test":{"get":{"tags":["Values"],"summary":"It's a test ! :)","operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[],"responses":{"200":{"description":"Success","schema":{"uniqueItems":false,"type":"array","items":{"type":"string"}}}}},"post":{"tags":["Values"],"operationId":"Post","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"value","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}}},"/api/test/{id}":{"get":{"tags":["Values"],"operationId":"Get","consumes":[],"produces":["text/plain","application/json","text/json"],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"Success","schema":{"type":"string"}}}},"put":{"tags":["Values"],"operationId":"Put","consumes":["application/json-patch+json","application/json","text/json","application/*+json"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"},{"name":"value","in":"body","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success"}}},"delete":{"tags":["Values"],"operationId":"Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"Success"}}}}},"definitions":{"AzureADAuthModel":{"type":"object","properties":{"apiKey":{"type":"string"}}},"Book":{"type":"object","properties":{"id":{"type":"string"},"bookName":{"type":"string"},"price":{"format":"double","type":"number"},"category":{"type":"string"},"author":{"type":"string"}}},"Device":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"location":{"type":"string"},"locationExplanation":{"type":"string"},"height":{"format":"int32","type":"integer"},"width":{"format":"int32","type":"integer"}}},"FacebookAuthModel":{"type":"object","properties":{"userAccessToken":{"type":"string"}}},"GoogleAuthModel":{"type":"object","properties":{"authorizationCode":{"type":"string"},"apiKey":{"type":"string"}}},"SmartPrinterMessage":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"time":{"type":"string"},"temperature":{"format":"double","type":"number"},"pressure":{"format":"double","type":"number"},"smoke":{"format":"int32","type":"integer"}}},"SmartGardenMessage":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"time":{"type":"string"},"temperature":{"format":"double","type":"number"},"pressure":{"format":"double","type":"number"},"humidity":{"format":"double","type":"number"},"water":{"format":"int32","type":"integer"},"light":{"format":"int32","type":"integer"}}},"UserInfo":{"type":"object","properties":{"id":{"type":"string"},"role":{"type":"string"},"email":{"type":"string"},"password":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"token":{"type":"string"},"birthday":{"type":"string"},"address":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"language":{"type":"string"},"timeZone":{"type":"string"},"postalCode":{"format":"int32","type":"integer"},"screenConfigurationIds":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/ScreenConfiguration"}},"deviceIds":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Device"}}}},"ScreenConfiguration":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"widgets":{"uniqueItems":false,"type":"array","items":{"$ref":"#/definitions/Widget"}},"height":{"format":"int32","type":"integer"},"width":{"format":"int32","type":"integer"}}},"Widget":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"displayName":{"type":"string"},"type":{"type":"string"},"activated":{"type":"boolean"},"form":{"type":"string"},"font":{"type":"string"},"color":{"type":"string"},"size":{"type":"string"},"width":{"format":"int32","type":"integer"},"height":{"format":"int32","type":"integer"},"positionX":{"format":"int32","type":"integer"},"positionY":{"format":"int32","type":"integer"}}},"User":{"type":"object","properties":{"id":{"type":"string"},"password":{"type":"string"}}},"TwitterAuthModel":{"type":"object","properties":{"apiKey":{"type":"string"}}}},"securityDefinitions":{"Bearer":{"name":"Authorization","in":"header","type":"apiKey","description":"Please enter JWT with Bearer into field"}},"security":[{"Bearer":[]}]} \ No newline at end of file