Skip to content

Instantly share code, notes, and snippets.

View yuka1984's full-sized avatar

Yuka=San yuka1984

  • http://www.sigmact.com/
  • Tokyo Japan
View GitHub Profile
public abstract class ApiFunctionBase
{
public ILogger Logger { get; protected set; }
public HttpRequest Request { get; protected set; }
protected virtual ApiError GetExceptionApiError(Exception e)
{
return new ApiError
{
[SwaggerIgnore]
[FunctionName("Swagger")]
public static Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "swagger/json")]
HttpRequestMessage req,
[SwashBuckleClient] ISwashBuckleClient swashBuckleClient)
{
return Task.FromResult(swashBuckleClient.CreateSwaggerDocumentResponse(req));
}
public class ProductCreateRequest
{
/// <summary>
/// Sku
/// </summary>
[MaxLength(32)]
[Required]
[JsonProperty("sku")]
public string Sku { get; set; }
[RequestHttpHeader("Idempotency-Key", isRequired: false)]
[RequestHttpHeader("Authorization", isRequired: true)]
[FunctionName("Api_AddItems")]
public async Task<IActionResult> Create(
[HttpTrigger(AuthorizationLevel.Function, "post", "product")]
[RequestBodyType(typeof(ProductCreateRequest), "product request")]HttpRequest request)
{
return new OkObjectResult(new ProductModel());
}
[FunctionName("Api_AddItems")]
public async Task<IActionResult> Create(
[HttpTrigger(AuthorizationLevel.Function, "post", "product")]
[RequestBodyType(typeof(ProductCreateRequest), "product request")]HttpRequest request)
{
return new OkObjectResult(new ProductModel());
}
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(ProductModel[]))]
[ProducesResponseType((int)HttpStatusCode.InternalServerError, Type = typeof(Error))]
[FunctionName("Api_GetItems")]
public async Task<IActionResult> GetItems(
[HttpTrigger(AuthorizationLevel.Function, "get", "product")]HttpRequest request)
{
return new OkObjectResult(new List<ProductModel>());
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using AzureFunctions.Extensions.Swashbuckle.Attribute;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using System.Net.Http;
using System.Threading.Tasks;
using AzureFunctions.Extensions.Swashbuckle;
using AzureFunctions.Extensions.Swashbuckle.Attribute;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
namespace SampleFunction
{
public static class SwaggerFunctions
using System.Reflection;
using AzureFunctions.Extensions.Swashbuckle;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using SampleFunction;
[assembly: WebJobsStartup(typeof(SwashBuckleStartup))]
namespace SampleFunction
{
internal class SwashBuckleStartup : IWebJobsStartup
@yuka1984
yuka1984 / a.cs
Created April 11, 2019 22:11
わかんないやつ
public abstract class EntityBase
{
public abstract string Name { get; }
}
public abstract class RepositoryBase<T> where T : EntityBase
{
private readonly string _name;
public RepositoryBase()