Azure / Azure/azure-functions-openapi-extension

Define the base url for the swagger document

Open
#445 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

I have an APIM resource in front of a function app. The swagger endpoints and the api endpoints are within the same function app resource but at the APIM, the swagger endpoints are hosted at /swagger/ and the api endpoints are at /api/. I was having issues that the base url used to render the API definition from the swagger UI endpoint was the backend function app url. I have since found that by adding the https://{apim}/swagger url to the OpenApi__HostNames environment variable will fix this and the swagger document loads with the api endpoints. However, they are not functional because the api endpoints are not at the https://{apim}/swagger url. I added a second url of https://{apim}/api and this did work but after selecting the correct server in the drop down.

I do not want users of the page to select a different server from the list. I tried to change the order of the urls in the environment variable but that caused the swagger.json not to be found.

Upon further investigation, I found that the SwaggerUI object in OpenApi.Core uses the first item in this list of servers as the base url of the swagger.json endpoint.

Is there a way to define the base url for the swagger.json endpoint separate from the list of hostnames?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.