Azure / Azure/azure-functions-openapi-extension
Unable to render swagger.json/UI when the HTTP GET function while the route contains only a parameter
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the issue**
Unable to render swagger.json/UI when the HTTP GET Azure function while the route contains only a parameter.
**To Reproduce**
Steps to reproduce the behavior:
1. Create a plain new azure function (.NET6 with HTTP trigger)
2. Install Microsoft.Azure.WebJobs.Extensions NuGet (1.4.0)
3. Specify some OpenApi attributes above the newly created function
4. Specify "Route" in the HttpTrigger attribute like so "{somePathParam}"
5. Add a new string parameter of the typed string right below "string somePathParam"
6. Run the function
7. Enter the swagger UI URL into the browser "http://localhost:{your-port}/api/swagger/ui
8. The swagger UI can't be rendered (if you look at "http://localhost:{your-port}/api/swagger.json"), you can see there is just a content that the defined function returns (i.e. the function that should be just documented according to the attributes is being called instead)
9. Try to add something to the Route definition like so "prefix/{somePathParam}", or "{somePathParam}/postfix"
10. Run the function again, visit the swagger UI or swagger,json URL, and voila, everything works as it should.
**Expected behavior**
The swagger.json, or UI should be generated even if there is only path parameter in the Route definition.
**Screenshots**
Does not work like this ...



... but does when it is like this.


**Environment:**
- OS: Windows 10
- Browser: Chrome/Brave
- Version: 1.4.0
**Additional context**
I am not sure whether this is a bug or intended behavior. I couldn't find any info, so if it is the case, I am sorry.
Contributor guide
Research direction
Reproduce the issue with a plain .NET 6 Azure HTTP-trigger function using an OpenAPI route containing only a parameter, then request /api/swagger.json and /api/swagger/ui. Trace the HTTP-trigger route handling and OpenAPI generation path; the fix is complete when both endpoints generate the document and UI instead of invoking the function.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100