Azure / Azure/azure-functions-openapi-extension
"Failed to fetch http://localhost:57773/api/swagger.json" when running from Azure Functions with Aspire
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
### Description
I've created a new Azure Functions project with new Aspire in Visual Studio 2022 using net9.0. Then, I've added NuGet depencency `Microsoft.Azure.Functions.Worker.Extensions.OpenApi` in version 1.5.1. When starting this, the default `Function1` and Swagger UI is listed in console output of the App as expected:
```
Functions:
Function1: [GET,POST] http://localhost:7227/api/Function1
RenderOAuth2Redirect: [GET] http://localhost:7227/api/oauth2-redirect.html
RenderOpenApiDocument: [GET] http://localhost:7227/api/openapi/{version}.{extension}
RenderSwaggerDocument: [GET] http://localhost:7227/api/swagger.{extension}
RenderSwaggerUI: [GET] http://localhost:7227/api/swagger/ui
```
When I now open http://localhost:7227/api/swagger/ui, I get an error `Failed to load API definition.` and `Fetch error,
Failed to fetch http://localhost:57773/api/swagger.json`. It looks like the Aspire port 7227 is not picked up by Swagger UI so it tries to load definitions from a wrong address.
### Steps to reproduce
See description.
Contributor guide
Assessment
This issue has not been assessed yet.