-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into release/swagger-2.0.0
- Loading branch information
Showing
33 changed files
with
895 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
samples/Aliencube.AzureFunctions.FunctionApp.Models/ApiResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Aliencube.AzureFunctions.FunctionApp.Models | ||
{ | ||
/// <summary> | ||
/// This represents the model entity for API response of Swagger Pet Store. | ||
/// </summary> | ||
public class ApiResponse | ||
{ | ||
/// <summary> | ||
/// Gets or sets the code. | ||
/// </summary> | ||
public int? Code { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the type. | ||
/// </summary> | ||
public string Type { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the message. | ||
/// </summary> | ||
public string Message { get; set; } | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
samples/Aliencube.AzureFunctions.FunctionApp.Models/Category.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Aliencube.AzureFunctions.FunctionApp.Models | ||
{ | ||
/// <summary> | ||
/// This represents the model entity for category of Swagger Pet Store. | ||
/// </summary> | ||
public class Category | ||
{ | ||
/// <summary> | ||
/// Gets or sets the category ID. | ||
/// </summary> | ||
public long? Id { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the name. | ||
/// </summary> | ||
public string Name { get; set; } | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
samples/Aliencube.AzureFunctions.FunctionApp.Models/Order.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
|
||
namespace Aliencube.AzureFunctions.FunctionApp.Models | ||
{ | ||
/// <summary> | ||
/// This represents the model entity for order of Swagger Pet Store. | ||
/// </summary> | ||
public class Order | ||
{ | ||
/// <summary> | ||
/// Gets or sets the order ID. | ||
/// </summary> | ||
public long? Id { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the pet ID. | ||
/// </summary> | ||
public long? PetId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the quantity. | ||
/// </summary> | ||
public int? Quantity { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or seets the date/time shipped. | ||
/// </summary> | ||
public DateTime? ShipDate { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the <see cref="OrderStatus"/> value. | ||
/// </summary> | ||
public OrderStatus? Status { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the value indicating whether the order is complete or not. | ||
/// </summary> | ||
public bool? Complete { get; set; } | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
samples/Aliencube.AzureFunctions.FunctionApp.Models/OrderStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
namespace Aliencube.AzureFunctions.FunctionApp.Models | ||
{ | ||
/// <summary> | ||
/// This specifies the order status. | ||
/// </summary> | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public enum OrderStatus | ||
{ | ||
/// <summary> | ||
/// Identifies as "placed". | ||
/// </summary> | ||
Placed = 1, | ||
|
||
/// <summary> | ||
/// Identifies as "approved". | ||
/// </summary> | ||
Approved = 2, | ||
|
||
/// <summary> | ||
/// Identifies as "delivered". | ||
/// </summary> | ||
Delivered = 3 | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
samples/Aliencube.AzureFunctions.FunctionApp.Models/Pet.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Collections.Generic; | ||
|
||
using Newtonsoft.Json; | ||
|
||
namespace Aliencube.AzureFunctions.FunctionApp.Models | ||
{ | ||
/// <summary> | ||
/// This represents the model entity for pet of Swagger Pet Store. | ||
/// </summary> | ||
public class Pet | ||
{ | ||
/// <summary> | ||
/// Gets or sets the pet ID. | ||
/// </summary> | ||
public long? Id { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the category. | ||
/// </summary> | ||
public Category Category { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the name. | ||
/// </summary> | ||
[JsonRequired] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the list of photo URLs. | ||
/// </summary> | ||
[JsonRequired] | ||
public List<string> PhotoUrls { get; set; } = new List<string>(); | ||
|
||
/// <summary> | ||
/// Gets or sets the list of tags. | ||
/// </summary> | ||
public List<Tag> Tags { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the <see cref="PetStatus"/> value. | ||
/// </summary> | ||
public PetStatus? Status { get; set; } | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
samples/Aliencube.AzureFunctions.FunctionApp.Models/PetStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
namespace Aliencube.AzureFunctions.FunctionApp.Models | ||
{ | ||
/// <summary> | ||
/// This specifices the pet status. | ||
/// </summary> | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public enum PetStatus | ||
{ | ||
/// <summary> | ||
/// Identifies as "available". | ||
/// </summary> | ||
Available = 1, | ||
|
||
/// <summary> | ||
/// Identifies as "pending". | ||
/// </summary> | ||
Pending = 2, | ||
|
||
/// <summary> | ||
/// Identifies as "sold". | ||
/// </summary> | ||
Sold = 3 | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
samples/Aliencube.AzureFunctions.FunctionApp.Models/Tag.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Aliencube.AzureFunctions.FunctionApp.Models | ||
{ | ||
/// <summary> | ||
/// This represents the model entity for tag of Swagger Pet Store. | ||
/// </summary> | ||
public class Tag | ||
{ | ||
/// <summary> | ||
/// Gets or sets the tag ID. | ||
/// </summary> | ||
public long? Id { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the name. | ||
/// </summary> | ||
public string Name { get; set; } | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
samples/Aliencube.AzureFunctions.FunctionApp.Models/User.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
namespace Aliencube.AzureFunctions.FunctionApp.Models | ||
{ | ||
/// <summary> | ||
/// This represents the model entity for user of Swagger Pet Store. | ||
/// </summary> | ||
public class User | ||
{ | ||
/// <summary> | ||
/// Gets or sets the user ID. | ||
/// </summary> | ||
public long? Id { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the username. | ||
/// </summary> | ||
public string Username { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the first name. | ||
/// </summary> | ||
public string FirstName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the last name. | ||
/// </summary> | ||
public string LastName { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the email. | ||
/// </summary> | ||
public string Email { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the password. | ||
/// </summary> | ||
public string Password { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the phone number. | ||
/// </summary> | ||
public string Phone { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the user status value. | ||
/// </summary> | ||
public int? UserStatus { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
samples/Aliencube.AzureFunctions.FunctionAppV1IoC/PetStoreHttpTrigger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
using Aliencube.AzureFunctions.Extensions.DependencyInjection; | ||
using Aliencube.AzureFunctions.Extensions.DependencyInjection.Abstractions; | ||
using Aliencube.AzureFunctions.Extensions.OpenApi.Attributes; | ||
using Aliencube.AzureFunctions.Extensions.OpenApi.Enums; | ||
using Aliencube.AzureFunctions.FunctionApp.Models; | ||
|
||
using Microsoft.Azure.WebJobs; | ||
using Microsoft.Azure.WebJobs.Extensions.Http; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.OpenApi.Models; | ||
|
||
namespace Aliencube.AzureFunctions.FunctionAppV1IoC | ||
{ | ||
public static class PetStoreHttpTrigger | ||
{ | ||
/// <summary> | ||
/// Gets the <see cref="IFunctionFactory"/> instance as an IoC container. | ||
/// </summary> | ||
public static IFunctionFactory Factory = new FunctionFactory<StartUp>(); | ||
|
||
[FunctionName(nameof(PetStoreHttpTrigger.AddPet))] | ||
[OpenApiOperation(operationId: "addPet", tags: new[] { "pet" }, Summary = "Add a new pet to the store", Description = "This add a new pet to the store.", Visibility = OpenApiVisibilityType.Important)] | ||
[OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be added to the store")] | ||
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "New pet details added", Description = "New pet details added")] | ||
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Invalid input", Description = "Invalid input")] | ||
public static async Task<HttpResponseMessage> AddPet( | ||
[HttpTrigger(AuthorizationLevel.Function, "POST", Route = "pet")] HttpRequestMessage req, | ||
ILogger log) | ||
{ | ||
return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); | ||
} | ||
|
||
[FunctionName(nameof(PetStoreHttpTrigger.UpdatePet))] | ||
[OpenApiOperation(operationId: "updatePet", tags: new[] { "pet" }, Summary = "Update an existing pet", Description = "This updates an existing pet.", Visibility = OpenApiVisibilityType.Important)] | ||
[OpenApiRequestBody(contentType: "application/json", bodyType: typeof(Pet), Required = true, Description = "Pet object that needs to be updated to the store")] | ||
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "Pet details updated", Description = "Pet details updated")] | ||
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] | ||
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] | ||
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Validation exception", Description = "Validation exception")] | ||
public static async Task<HttpResponseMessage> UpdatePet( | ||
[HttpTrigger(AuthorizationLevel.Function, "PUT", Route = "pet")] HttpRequestMessage req, | ||
ILogger log) | ||
{ | ||
return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); | ||
} | ||
|
||
[FunctionName(nameof(PetStoreHttpTrigger.FindByStatus))] | ||
[OpenApiOperation(operationId: "findPetsByStatus", tags: new[] { "pet" }, Summary = "Finds Pets by status", Description = "Multiple status values can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] | ||
[OpenApiParameter(name: "status", In = ParameterLocation.Query, Required = true, Type = typeof(List<PetStatus>), Summary = "Pet status value", Description = "Status values that need to be considered for filter", Visibility = OpenApiVisibilityType.Important)] | ||
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List<Pet>), Summary = "successful operation", Description = "successful operation")] | ||
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid status value", Description = "Invalid status value")] | ||
public static async Task<HttpResponseMessage> FindByStatus( | ||
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "pet/findByStatus")] HttpRequestMessage req, | ||
ILogger log) | ||
{ | ||
return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); | ||
} | ||
|
||
[FunctionName(nameof(PetStoreHttpTrigger.FindByTags))] | ||
[OpenApiOperation(operationId: "findPetsByTags", tags: new[] { "pet" }, Summary = "Finds Pets by tags", Description = "Muliple tags can be provided with comma separated strings.", Visibility = OpenApiVisibilityType.Important)] | ||
[OpenApiParameter(name: "tags", In = ParameterLocation.Query, Required = true, Type = typeof(List<string>), Summary = "Tags to filter by", Description = "Tags to filter by", Visibility = OpenApiVisibilityType.Important)] | ||
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(List<Pet>), Summary = "successful operation", Description = "successful operation")] | ||
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid tag value", Description = "Invalid tag value")] | ||
public static async Task<HttpResponseMessage> FindByTags( | ||
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/findByTags")] HttpRequestMessage req, | ||
ILogger log) | ||
{ | ||
return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); | ||
} | ||
|
||
[FunctionName(nameof(PetStoreHttpTrigger.GetPetById))] | ||
[OpenApiOperation(operationId: "getPetById", tags: new[] { "pet" }, Summary = "Find pet by ID", Description = "Returns a single pet.", Visibility = OpenApiVisibilityType.Important)] | ||
[OpenApiParameter(name: "petId", In = ParameterLocation.Path, Required = true, Type = typeof(long), Summary = "ID of pet to return", Description = "ID of pet to return", Visibility = OpenApiVisibilityType.Important)] | ||
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Pet), Summary = "successful operation", Description = "successful operation")] | ||
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.BadRequest, Summary = "Invalid ID supplied", Description = "Invalid ID supplied")] | ||
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Summary = "Pet not found", Description = "Pet not found")] | ||
public static async Task<HttpResponseMessage> GetPetById( | ||
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "pet/{petId}")] HttpRequestMessage req, | ||
long petId, | ||
ILogger log) | ||
{ | ||
return await Task.FromResult(req.CreateResponse(HttpStatusCode.OK)).ConfigureAwait(false); | ||
} | ||
} | ||
} |
Oops, something went wrong.