Skip to content

Commit b2c1028

Browse files
committed
feature: Added object result to function, made swagger functions public, added npm package folder
1 parent 97501b7 commit b2c1028

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

DummyFunction/DummyFunction.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.ComponentModel.DataAnnotations;
2+
using System.Linq;
23
using System.Net;
3-
using System.Threading.Tasks;
44
using Microsoft.AspNetCore.Http;
55
using Microsoft.Azure.WebJobs;
66
using Microsoft.Azure.WebJobs.Extensions.Http;
@@ -13,18 +13,26 @@ public class DummyFunction
1313
{
1414
[FunctionName("DummyFunction")]
1515
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(DummyResponseDto))]
16-
public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Admin, "get", Route = "dummyFunction")] HttpRequest req, ILogger log)
16+
public IActionResult Run([HttpTrigger(AuthorizationLevel.Admin, "get", Route = "dummyFunction")] HttpRequest req, ILogger log)
1717
{
18-
return new OkObjectResult("hey!");
18+
return new ObjectResult(new DummyResponseDto
19+
{
20+
Greeting = "Hey!",
21+
Emoji = "👷🏻‍",
22+
NestedThingies = Enumerable.Range(0, 5).Select(x => new DummyNestedDto
23+
{
24+
ImportantNumber = x
25+
}).ToArray()
26+
});
1927
}
2028
}
2129

2230
public class DummyResponseDto
2331
{
24-
public string Text { get; set; }
32+
public string Emoji { get; set; }
2533

2634
[Required]
27-
public string RequiredText { get; set; }
35+
public string Greeting { get; set; }
2836

2937
public DummyNestedDto[] NestedThingies { get; set; }
3038
}

SwaggerFunctions/SwaggerFunctions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class SwaggerFunctions
1212
[SwaggerIgnore]
1313
[FunctionName("Swagger")]
1414
public Task<HttpResponseMessage> Swagger(
15-
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "swagger/json")]
15+
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "swagger/json")]
1616
HttpRequestMessage req,
1717
[SwashBuckleClient] ISwashBuckleClient swashBuckleClient)
1818
{
@@ -22,7 +22,7 @@ public Task<HttpResponseMessage> Swagger(
2222
[SwaggerIgnore]
2323
[FunctionName("SwaggerUi")]
2424
public Task<HttpResponseMessage> SwaggerUi(
25-
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "swagger/ui")]
25+
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "swagger/ui")]
2626
HttpRequestMessage req,
2727
[SwashBuckleClient] ISwashBuckleClient swashBuckleClient)
2828
{

Types/.releaserc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"release": {
3+
"branches": [ "master" ]
4+
}
5+
}

Types/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Types/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "azure-functions-sample-types",
3+
"author": "Michał Żołnieruk",
4+
"version": "0.0.0-dev",
5+
"dependencies": {
6+
"typescript": "~3.7.2"
7+
}
8+
}

0 commit comments

Comments
 (0)