I am trying to create an azure function app with two http trigger functions in it with open API specs, but both using same route but with different parameters.
Requirement to fetch some templates from Database. first way is when customer provides id, another way when customer provides name
Here is my function looks like
[FunctionName("GetTemplateById")]
[OpenApiOperation(operationId: "Get-Template", tags: new[] { "Get-Template" })]
[OpenApiParameter(name: "id", In = ParameterLocation.Query, Required = true, Description = "template id")]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(JObject), Description = "The OK response")]
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.Unauthorized, Summary = "Unauthorized Access", Description = "Unauthorized Access.")]
public async Task<IActionResult> GetTemplateById(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "template")] HttpRequest req)
{
//some code using id parameter
return new ObjectResult(response);
}
But I need another function where to fetch template by template name instead of ID. But how can I make it with the same route, but different parameter. I am not thinking about a solution where both parameters in single function and making both optional. Any other workaround?