azure-functions-openapi-extension icon indicating copy to clipboard operation
azure-functions-openapi-extension copied to clipboard

Define the base url for the swagger document

Open ChrisDev3 opened this issue 3 years ago • 0 comments

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?

ChrisDev3 avatar May 26 '22 18:05 ChrisDev3