Skip to content

Commit

Permalink
fixing auth for HttpTrigger with OpenAPI template
Browse files Browse the repository at this point in the history
  • Loading branch information
soninaren committed May 11, 2021
1 parent c93c654 commit 3590b69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
],
"replaces": "AuthLevelValue",
"defaultValue": "Function"
},
"AuthEnabled": {
"type": "computed",
"value": "(AccessRights == \"Function\" || AccessRights == \"Admin\")"
}
},
"primaryOutputs": [
Expand All @@ -57,7 +61,7 @@
"args": {
"referenceType": "package",
"reference": "Microsoft.Azure.WebJobs.Extensions.OpenApi",
"version": "0.7.1-preview",
"version": "0.7.2-preview",
"projectFileExtensions": ".csproj"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public static class HttpTriggerWithOpenAPICSharp
{
[FunctionName("HttpTriggerWithOpenAPICSharp")]
[OpenApiOperation(operationId: "Run", tags: new[] { "name" })]
#if (AuthEnabled)
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
#endif
[OpenApiParameter(name: "name", In = ParameterLocation.Query, Required = true, Type = typeof(string), Description = "The **Name** parameter")]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "text/plain", bodyType: typeof(string), Description = "The OK response")]
public static async Task<IActionResult> Run(
Expand Down

0 comments on commit 3590b69

Please sign in to comment.