csharp-functions.function.mustache Maven / Gradle / Ivy
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Attributes;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Org.OpenAPITools.Models;
namespace {{apiPackage}}
{ {{#operations}}
public partial {{#classModifier}}{{classModifier}} {{/classModifier}}class {{classname}}
{ {{#operation}}
[FunctionName("{{classname}}_{{operationId}}")]
public async Task> _{{operationId}}([HttpTrigger(AuthorizationLevel.Anonymous, "{{httpMethod}}", Route = "{{{apiBasePath}}}{{{path}}}")]HttpRequest req, ExecutionContext context{{#allParams}}{{#isPathParam}}, {{>pathParam}}{{/isPathParam}}{{/allParams}}){{^generateBody}};{{/generateBody}}
{{#generateBody}}
{
var method = this.GetType().GetMethod("{{operationId}}");
return method != null
? (await ((Task<{{{returnType}}}>)method.Invoke(this, new object[] { req, context{{#allParams}}{{#isPathParam}}, {{>paramName}}{{/isPathParam}}{{/allParams}} })).ConfigureAwait(false))
: new StatusCodeResult((int)HttpStatusCode.NotImplemented);
}
{{/generateBody}}
{{/operation}}
}
{{/operations}}
}