Describe the issue
When a parameter is included for a "get", the parameter either does not pass the correct value (parameter is a string) or it causes an error (parameter is an integer)
To Reproduce
[Function("Get1")]
[OpenApiOperation(operationId: "Get1")]
[OpenApiParameter(name: "id", In = ParameterLocation.Query, Required = true, Type = typeof(int), Description = "User Id")]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(string), Description = "The OK response message containing a JSON result.")]
public IActionResult Get1([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "Get1/{id}")] HttpRequest req, int id)
{
string parameter = id.ToString();
string response = $"You passed in {parameter}.";
return new OkObjectResult(response);
}
[Function("Get2")]
[OpenApiOperation(operationId: "Get2")]
[OpenApiParameter(name: "id", In = ParameterLocation.Query, Required = true, Type = typeof(string), Description = "User Id")]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(string), Description = "The OK response message containing a JSON result.")]
public IActionResult Get2([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "Get2/{id}")] HttpRequest req, string id)
{
string response = $"You passed in {id}.";
return new OkObjectResult(response);
}
Expected behavior
Get1 should successfully pass in the number one when called with "Get1/1". Instead, it throws the following error : Cannot convert input parameter 'id' to type 'System.Int32' from type 'System.String')
Get2 should successfully pass in the string 'abc' when called with "Get2/abc". The parameter id has the value of "{id}"
Screenshots
Environment (please complete the following information, if applicable):
Describe the issue When a parameter is included for a "get", the parameter either does not pass the correct value (parameter is a string) or it causes an error (parameter is an integer)
To Reproduce [Function("Get1")] [OpenApiOperation(operationId: "Get1")] [OpenApiParameter(name: "id", In = ParameterLocation.Query, Required = true, Type = typeof(int), Description = "User Id")] [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(string), Description = "The OK response message containing a JSON result.")] public IActionResult Get1([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "Get1/{id}")] HttpRequest req, int id) { string parameter = id.ToString(); string response = $"You passed in {parameter}."; return new OkObjectResult(response); }
[Function("Get2")] [OpenApiOperation(operationId: "Get2")] [OpenApiParameter(name: "id", In = ParameterLocation.Query, Required = true, Type = typeof(string), Description = "User Id")] [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(string), Description = "The OK response message containing a JSON result.")] public IActionResult Get2([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "Get2/{id}")] HttpRequest req, string id) { string response = $"You passed in {id}."; return new OkObjectResult(response); }
Expected behavior Get1 should successfully pass in the number one when called with "Get1/1". Instead, it throws the following error : Cannot convert input parameter 'id' to type 'System.Int32' from type 'System.String') Get2 should successfully pass in the string 'abc' when called with "Get2/abc". The parameter id has the value of "{id}"
Screenshots
Environment (please complete the following information, if applicable):