question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support "catch all" http trigger route

See original GitHub 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

[FunctionName("CatchAll")]
[OpenApiOperation(operationId: "CatchAll", tags: new[] { "name" })]
[OpenApiParameter("path", In = ParameterLocation.Path, Type = typeof(string))]
[OpenApiResponseWithoutBody(HttpStatusCode.OK)]
public static ActionResult CatchAll([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "catchall/{*path}")]
                                                 HttpRequest req,
                                                 string path)
{
    return new OkObjectResult(path);
}

Actual behavior

image

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shibayancommented, Mar 18, 2021

@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": { }
}
0reactions
justinyoocommented, Apr 9, 2021

@shibayan Yeah, it’s not something I can do on my end. If you Google it, there are so many discussions around - from the spec wise to the implementation perspective.

I’m not too sure, we can get it through the proxies.json file. Let me try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create a HttpTrigger that will match any url?
I have discovered you can match anything with a * at the start of the parameter name Route = "{*any}" will match any...
Read more >
Azure Functions HTTP trigger
The HTTP trigger lets you invoke a function with an HTTP request. ... "get", "post", Route = null)] HttpRequest req, ILogger log) {...
Read more >
Azure Functions: Wildcard Routing
A quick tip to support wildcard routes in Azure Functions. ... What you need is a way to set up a wildcard route...
Read more >
Azure Functions HTTP triggers and bindings overview
Learn to use HTTP triggers and bindings in Azure Functions. ... routePrefix, api, The route prefix that applies to all routes.
Read more >
Customize default route on domain root level #848
If the function gets triggered via the default route on domain root ... can define a route that matches the root without using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found