Skip to content
This repository was archived by the owner on Jun 3, 2023. It is now read-only.

Basic usage with HttpExtensions

Jussi Saarivirta edited this page Feb 16, 2019 · 2 revisions

The basics

With HttpExtensions things get a bit simpler as you no longer need to add annotations to your Functions. The same basics apply as before but basically you need to do less, unless you use the more advanced features like authentication.

Your basic function with HttpExtensions looks something like this:

[SwaggerResponse(200, typeof(MyResponse))]
[FunctionName("hello")]
public static async Task<IActionResult> Hello(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "hello")] HttpRequest req,
    [HttpQuery(Required = true)]HttpParam<string> name,
    [HttpQuery(Required = true)]HttpParam<int> age,
    ILogger log)
{
    return new OkObjectResult(new MyResponse() {Message = $"Hello {name}, {age} is a nice age!"});
}

So as you can see, pretty plain and simple, nothing Swagger specific here except the response annotation. The parameters get picked up automatically and need no annotations.