Skip to content

Commit af42aaf

Browse files
justinyooDoHoon Kim
authored andcommitted
Update docs for 0.9.0-preview (Azure#256)
1 parent 7db0d2f commit af42aaf

File tree

4 files changed

+295
-127
lines changed

4 files changed

+295
-127
lines changed

docs/openapi-core.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,27 @@ public class OpenApiConfigurationOptions : IOpenApiConfigurationOptions
139139
```
140140

141141

142+
### Force HTTP or HTTPS for Swagger UI ###
143+
144+
> **NOTE**: If you use the [Linux Dedicated Plan](https://docs.microsoft.com/azure/azure-functions/dedicated-plan?WT.mc_id=github-0000-juyoo), you can consider this HTTP/HTTPS enforcement settings.
145+
146+
If you want to force either HTTP or HTTPS, configure the following properties on the `IOpenApiConfigurationOptions` interface.
147+
148+
```csharp
149+
public class OpenApiConfigurationOptions : IOpenApiConfigurationOptions
150+
{
151+
...
152+
153+
public bool ForceHttps { get; set; } = true;
154+
public bool ForceHttp { get; set; } = true;
155+
156+
...
157+
}
158+
```
159+
160+
You can set either property to `true`, and based on the combination of both, your Swagger UI renders contents through either HTTP or HTTPS. However, if you set both properties to `true`, HTTPS takes precedence.
161+
162+
142163
### Inheriting `DefaultOpenApiConfigurationOptions` ###
143164

144165
Instead of implementing `IOpenApiConfigurationOptions`, you can inherit `DefaultOpenApiConfigurationOptions`. As `Info`, `Servers` and `OpenApiVersion` properties have the modifier of `virtual`, you can freely override them or leave them as default.
@@ -172,6 +193,9 @@ public class MyOpenApiConfigurationOptions : DefaultOpenApiConfigurationOptions
172193
};
173194

174195
public override OpenApiVersionType OpenApiVersion { get; set; } = OpenApiVersionType.V3;
196+
197+
// Consider Linux Dedicated Plan only.
198+
public override bool ForceHttps { get; set; } = true;
175199
}
176200
```
177201

docs/openapi-in-proc.md

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -28,80 +28,6 @@ While using this library, if you find any issue, please raise a ticket on the [I
2828
For detailed getting started document, find this [Enable OpenAPI Endpoints on Azure Functions (Preview) – In-Process Model](enable-open-api-endpoints-in-proc.md) page.
2929

3030

31-
## Configuration ##
31+
## Advanced Configuration in General ##
3232

33-
For the extension's advanced configuration, it expects the following config keys.
34-
35-
36-
### Configure Authorization Level ###
37-
38-
As a default, all endpoints to render Swagger UI and OpenAPI documents have the authorisation level of `AuthorizationLevel.Anonymous`. However, if you want to secure those endpoints, change their authorisation level to `AuthorizationLevel.Function` and pass the API Key through either request header or querystring parameter. This can be done through the environment variables. Here's the sample `local.settings.json` file. The other values are omitted for brevity.
39-
40-
```json
41-
{
42-
"Values": {
43-
"OpenApi__ApiKey": "",
44-
"OpenApi__AuthLevel__Document": "Anonymous",
45-
"OpenApi__AuthLevel__UI": "Anonymous"
46-
}
47-
}
48-
```
49-
50-
You can have granular controls to both Swagger UI and OpenAPI documents by setting the authorisation level to `Anonymous`, `User`, `Function`, `System` or `Admin`. Make sure that you MUST provide the `OpenApi__AuthKey` value, if you choose the `OpenApi__AuthLevel__Document` value other than `Anonymous`. Otherwise, it will throw an error.
51-
52-
> [!NOTE]
53-
> Both Swagger UI and OpenAPI document pages are allowed `Anonymous` access by default.
54-
55-
56-
### Configure Swagger UI Visibility ###
57-
58-
You may want to only enable the Swagger UI page during the development time, and disable the page when publishing it to Azure. You can configure an environment variable to enable/disable the Swagger UI page. Here's the sample `local.settings.json` file. The other values are omitted for brevity.
59-
60-
```json
61-
{
62-
"Values": {
63-
"OpenApi__HideSwaggerUI": "false"
64-
}
65-
}
66-
```
67-
68-
If you set the `OpenApi__HideSwaggerUI` value to `true`, the Swagger UI page won't be showing up, and you will see the 404 error.
69-
70-
> [!NOTE]
71-
> The default value for `OpenApi__HideSwaggerUI` is `false`.
72-
73-
74-
### Configure OpenAPI Information ###
75-
76-
As a default, the OpenAPI document automatically generated provides a minimum set of information like:
77-
78-
* OpenAPI Version: `2.0`
79-
* OpenAPI Document Title: `OpenAPI Document on Azure Functions`
80-
* OpenAPI Document Version: `1.0.0`
81-
82-
You may want to provide consumers with more details by implementing the `IOpenApiConfigurationOptions` interface or inheriting the `DefaultOpenApiConfigurationOptions` class. On the other hand, you can use the following environment variables to avoid the app from being recompiled and redeployed. Here's the sample `local.settings.json` file. The other values are omitted for brevity.
83-
84-
```json
85-
{
86-
"Values": {
87-
"OpenApi__Version": "v2",
88-
"OpenApi__DocTitle": "Azure Functions OpenAPI Extension",
89-
"OpenApi__DocVersion": "1.0.0"
90-
}
91-
}
92-
```
93-
94-
95-
### Configure Custom Base URLs ###
96-
97-
There's a chance that you want to expose the UI and OpenAPI document through [Azure API Management](https://docs.microsoft.com/azure/api-management/api-management-key-concepts?WT.mc_id=github-0000-juyoo) or load balancing services like [Azure Front Door](https://docs.microsoft.com/azure/frontdoor/front-door-overview?WT.mc_id=github-0000-juyoo). You can configure an environment variable to add them. Here's the sample `local.settings.json` file. The other values are omitted for brevity.
98-
99-
```json
100-
{
101-
"Values": {
102-
"OpenApi__HostNames": "https://contoso.com/api/,https://fabrikam.com/api/"
103-
}
104-
}
105-
```
106-
107-
> **NOTE**: This multiple hostnames support feature only works with OpenAPI 3.x, not OpenAPI 2.x.
33+
If you look for the advanced configurations in general, please find the document, [Advanced Configurations for OpenAPI Extension](./openapi.md)

docs/openapi-out-of-proc.md

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,6 @@ While using this library, if you find any issue, please raise a ticket on the [I
2222
For detailed getting started document, find this [Enable OpenAPI Endpoints on Azure Functions (Preview) – Out-of-Process Model](enable-open-api-endpoints-out-of-proc.md) page.
2323

2424

25-
## Configuration ##
25+
## Advanced Configuration in General ##
2626

27-
For the extension's advanced configuration, it expects the following config keys.
28-
29-
30-
### Configure Authorization Level ###
31-
32-
As a default, all endpoints to render Swagger UI and OpenAPI documents have the authorisation level of `AuthorizationLevel.Anonymous`.
33-
34-
> **NOTE**: Currently, this out-of-process worker extension only supports the `AuthorizationLevel.Anonymous` access.
35-
36-
37-
### Configure Swagger UI Visibility ###
38-
39-
Unlike the in-process worker model, this out-of-process worker model currently doesn't support hiding Swagger UI.
40-
41-
42-
### Configure OpenAPI Information ###
43-
44-
As a default, the OpenAPI document automatically generated provides a minimum set of information like:
45-
46-
* OpenAPI Version: `2.0`
47-
* OpenAPI Document Title: `OpenAPI Document on Azure Functions`
48-
* OpenAPI Document Version: `1.0.0`
49-
50-
You may want to provide consumers with more details by implementing the `IOpenApiConfigurationOptions` interface or inheriting the `DefaultOpenApiConfigurationOptions` class. On the other hand, you can use the following environment variables to avoid the app from being recompiled and redeployed. Here's the sample `local.settings.json` file. The other values are omitted for brevity.
51-
52-
```json
53-
{
54-
"Values": {
55-
"OpenApi__Version": "v2",
56-
"OpenApi__DocTitle": "Azure Functions OpenAPI Extension",
57-
"OpenApi__DocVersion": "1.0.0"
58-
}
59-
}
60-
```
61-
62-
63-
### Configure Custom Base URLs ###
64-
65-
There's a chance that you want to expose the UI and OpenAPI document through [Azure API Management](https://docs.microsoft.com/azure/api-management/api-management-key-concepts?WT.mc_id=github-0000-juyoo) or load balancing services like [Azure Front Door](https://docs.microsoft.com/azure/frontdoor/front-door-overview?WT.mc_id=github-0000-juyoo). You can configure an environment variable to add them. Here's the sample `local.settings.json` file. The other values are omitted for brevity.
66-
67-
```json
68-
{
69-
"Values": {
70-
"OpenApi__HostNames": "https://contoso.com/api/,https://fabrikam.com/api/"
71-
}
72-
}
73-
```
74-
75-
> **NOTE**: This multiple hostnames support feature only works with OpenAPI 3.x, not OpenAPI 2.x.
27+
If you look for the advanced configurations in general, please find the document, [Advanced Configurations for OpenAPI Extension](./openapi.md)

0 commit comments

Comments
 (0)