Azure / Azure/azure-functions-openapi-extension

Add more options to control exposed Swagger endpoints

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

Description

**Describe the issue**

I have a business requirement to customize the Swagger endpoints:
- [ ] Hide the Swagger UI endpoint and expose only the swagger.json endpoint
- [ ] Update the swagger.json endpoint to align with other endpoints used in my applications i.e. /api-docs/swagger.json

I am using .NET 8 and the out-of-processes worker model.

**To Reproduce**
This is a new feature request with no steps on how to reproduce.

**Expected behavior**
By default, the library creates three endpoints. I only need the RenderSwaggerDocument endpoint and the others should be hidden.
```ps
RenderOpenApiDocument: [GET] https://localhost:7001/openapi/{version}.{extension}
RenderSwaggerDocument: [GET] https://localhost:7001/swagger.{extension}
RenderSwaggerUI: [GET] https://localhost:7001/swagger/ui
```
**Screenshots**

**Environment (please complete the following information, if applicable):**
- OS: Windows
- Azure Functions Core Tools Version: 4.0.5455 Commit hash: N/A (64-bit)
- Function Runtime Version: 4.27.5.21554

**Additional context**
[Configure Swagger UI Visibility](https://github.com/Azure/azure-functions-openapi-extension/blob/main/docs/openapi.md#configure-swagger-ui-visibility) suggests setting the `OpenApi__HideSwaggerUI` value to `true` in `local.settings.json` or application environment variables in production, the Swagger UI page won't be showing up, and you will see the 404 error. However, note that we are using the out-of-process worker model and...
> NOTE: Currently, the out-of-process worker model doesn't support hiding Swagger UI. The following configurations are only applicable to the in-process worker extension.

[Configure Custom Base URLs](https://github.com/Azure/azure-functions-openapi-extension/blob/main/docs/openapi.md#configure-custom-base-urls) doesn't seem to work. Even after setting `OpenApi__HostNames` to `/api-docs` in `local.settings.json`.

I tried to use proxies.json (as described in [Shortening Swagger UI Page URL and swagger.json URL with proxies.json](https://github.com/Azure/azure-functions-openapi-extension/blob/main/docs/shortening-swagger-ui-page-url.md#shortening-swagger-ui-page-url-and-swaggerjson-url-with-proxiesjson)) to implement the customisation of the end-points, but I get the error below:
![image](https://github.com/Azure/azure-functions-openapi-extension/assets/123918893/4c318a65-a655-43dc-af4d-62cd17d3e628)

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.