Open shibayan opened 3 years ago
@shibayan Thanks for the issue! The actual function endpoint itself works fine, if you send a request directly to the endpoint like:
curl http://localhost:7071/api/catchall/hello/world
However, like you mentioned, I can confirm that it doesn't work on the UI as expected. I'm not sure it's the issue on my end or the UI's end.
Have you got the similar experience with Swagger UI on other application like ASP.NET Core Web API with Swashbuckle?
@justinyoo
I tried the same route with the ASP.NET Core Web API with Swashbuckle, and it worked. Looking at the generated openapi definition, it seems that "*" should not be included in the definition.
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
[HttpGet("{*path}")]
public ActionResult Get(string path)
{
return Ok(path);
}
}
{
"openapi": "3.0.1",
"info": {
"title": "WebApplication6",
"version": "v1"
},
"paths": {
"/api/Values/{path}": {
"get": {
"tags": [
"Values"
],
"parameters": [
{
"name": "path",
"in": "path",
"required": true,
"schema": {
"type": "string",
"nullable": true
}
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
}
},
"components": { }
}
Thanks for confirming! Let me have a look.
@shibayan I looked at the issue. However, if the wildcard character is omitted, it actually changes the semantics of the endpoint. In other words, the following path template implies the {*path}
can be hello
, hello/world
or hello/world/lorem/ipsum
.
/catchall/{*path}
But the following path template implies the {path}
can only be hello
or world
, not hello/world
/catchall/{path}
I can change the path template from /catchall/{*path}
to /catchall/{path}
so that the OpenAPI doc shows the latter but, like I said, it changes semantics. Even though I applied the change to Swagger UI, it doesn't work properly either. It should be the UI's issue, not ours.
@justinyoo Thanks for the reply. I don't think the URL encoding of parameters is a Swagger UI issue, so I don't think it needs to be addressed, but I think the "catch all" parameter not being included in the OpenAPI definition is another issue.
Writing a route like
{*path}
and{**path}
to get all subsequent path parameters did not correctly output the OpenAPI definition.Microsoft.Azure.WebJobs.Extensions.OpenApi
:0.5.1-preview
Repro code
Actual behavior