You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/openapi-cli.md
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,11 @@ This generates Open API document through command-line without having to run the
12
12
* In order to read JSON configuration on Azure Functions 1.x, these extensions have copied the source code of [Microsoft.Extensions.Configuration.Json](https://github.com/aspnet/Extensions/tree/master/src/Configuration/Config.Json) to make use of [Newtonsoft.Json 9.0.1](https://www.nuget.org/packages/Newtonsoft.Json/9.0.1) under the [MIT License](http://opensource.org/licenses/MIT).
13
13
14
14
15
+
## Issues? ##
16
+
17
+
While using this CLI, if you find any issue, please raise a ticket on the [Issue](https://github.com/aliencube/AzureFunctions.Extensions/issues) page.
18
+
19
+
15
20
## Getting Started ##
16
21
17
22
### Download CLI ###
@@ -60,12 +65,12 @@ For Linux/MacOS
60
65
61
66
Here are options:
62
67
63
-
*`--project|-p`: Project path. It can be a fully qualified project path including `.csproj` or project directory. Default is the current directory.
64
-
*`--configuration|-c`: Configuration value. It can be either `Debug`, `Release` or something else. Default is `Debug`.
65
-
*`--target|-t`: Target framework. It should be `net4x` for Azure Functions v1, `netcoreapp2.x` for Azure Functions v2, and `netcoreapp3.x` for Azure Functions v3. Default is `netcoreapp2.1`.
66
-
*`--version|-v`: Open API spec version. It should be either `v2` or `v3`. Default is `v2`.
67
-
*`--format|-f`: Open API document format. It should be either `json` or `yaml`. Default is `json`.
68
-
*`--output|-o`: Output directory for the generated Open API document. It can be a fully qualified directory path or relative path from `<PROJECT_ROOT>/bin/<CONFIGURATION>/<TARGET_FRAMEWORK>`. Default is `output`.
68
+
*`-p|--project`: Project path. It can be a fully qualified project path including `.csproj` or project directory. Default is the current directory.
69
+
*`-c|--configuration`: Configuration value. It can be either `Debug`, `Release` or something else. Default is `Debug`.
70
+
*`-t|--target`: Target framework. It should be `net4x` for Azure Functions v1, `netcoreapp2.x` for Azure Functions v2, and `netcoreapp3.x` for Azure Functions v3. Default is `netcoreapp2.1`.
71
+
*`-v|--version`: Open API spec version. It should be either `v2` or `v3`. Default is `v2`.
72
+
*`-f|--format`: Open API document format. It should be either `json` or `yaml`. Default is `json`.
73
+
*`-o|--output`: Output directory for the generated Open API document. It can be a fully qualified directory path or relative path from `<PROJECT_ROOT>/bin/<CONFIGURATION>/<TARGET_FRAMEWORK>`. Default is `output`.
69
74
*`--console`: Value indicating whether to display the generated document to console or not. Default is `false`.
Copy file name to clipboardExpand all lines: docs/openapi.md
+87-46Lines changed: 87 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,76 +13,83 @@ This enables Azure Functions to render Open API document and Swagger UI. The mor
13
13
*[Swagger UI](https://github.com/swagger-api/swagger-ui) version used for this library is [3.20.5](https://github.com/swagger-api/swagger-ui/releases/tag/v3.20.5) under the [Apache 2.0 license](https://opensource.org/licenses/Apache-2.0).
14
14
15
15
16
+
## Issues? ##
17
+
18
+
While using this library, if you find any issue, please raise a ticket on the [Issue](https://github.com/aliencube/AzureFunctions.Extensions/issues) page.
19
+
20
+
16
21
## Getting Started ##
17
22
18
-
### Install Open API Templates ###
23
+
### Install NuGet Package ###
24
+
25
+
In order for your Azure Functions app to enable Open API capability, download the following NuGet package into your Azure Functions project.
### Option 1. Install Open API Boilerplate Templates ###
19
33
20
34
This is the easiest way to integrate the Open API document rendering. Run the following script based on your preference, which will install the pre-defined Open API document rendering endpoints.
21
35
36
+
22
37
#### Download Installation Scripts ###
23
38
24
-
First of all, download the installation script from GitHub.
39
+
Download the installation script using the PowerShell command.
Alternatively, download the installation script using the Bash shell command. Make sure that the downloaded script MUST become executable.
49
+
33
50
```bash
34
51
# Bash
35
-
curl -X GET "https://raw.githubusercontent.com/aliencube/AzureFunctions.Extensions/dev/scripts/Install-OpenApiHttpTriggerTemplates.sh">"scripts/Install-OpenApiHttpTriggerTemplates.sh"
52
+
curl -X GET "https://raw.githubusercontent.com/aliencube/AzureFunctions.Extensions/dev/scripts/Install-OpenApiHttpTriggerTemplates.sh" \
@@ -118,9 +127,9 @@ public static async Task<IActionResult> RenderSwaggerDocument(
118
127
> **NOTE**: In order to render payload definitions in `camelCasing`, add `new CamelCaseNamingStrategy()` as an optional argument to the `Build()` method. If this is omitted, payload will be rendered as defined in the payload definitions.
119
128
120
129
121
-
###Rendering Swagger UI ###
130
+
#### Swagger UI Page Endpoint ####
122
131
123
-
In order to render Swagger UI, define another HTTP endpoint for it:
132
+
In order to render the Swagger UI page, define the HTTP endpoint for it.
124
133
125
134
```csharp
126
135
[FunctionName(nameof(RenderSwaggerUI))]
@@ -132,7 +141,7 @@ public static async Task<IActionResult> RenderSwaggerUI(
@@ -152,15 +161,47 @@ public static async Task<IActionResult> RenderSwaggerUI(
152
161
```
153
162
154
163
155
-
##Open API Metadata##
164
+
### Expose Endpoints to Open API Document ###
156
165
157
-
To generate an Open API document, [OpenApiInfo object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#infoObject) needs to be defined. This information can be declared in three places –`host.json`, `openapisettings.json` or `local.settings.json`.
166
+
In order to include HTTP endpoints into the Open API document, use attribute classes (decorators) like:
* The Open API related endpoints has the `AuthorizationLevel` value other than `Anonymous`.
188
+
189
+
If the above conditions are met, add the following key to your `locall.settings.json` or App Settings blade on Azure.
190
+
191
+
*`OpenApi__ApiKey`: either the host key value or the master key value.
192
+
193
+
> **NOTE**: It is NOT required if your Open API related endpoints are set to the authorisation level of `Anonymous`.
194
+
195
+
196
+
## Open API Metadata Configuration ##
197
+
198
+
To generate an Open API document, [OpenApiInfo object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#infoObject) needs to be defined. This information can be declared in **ONE OF THREE** places –`host.json`, `openapisettings.json` or `local.settings.json`.
158
199
159
200
This library looks for the information in the following order:
160
201
161
202
1.`host.json`
162
203
2.`openapisettings.json`
163
-
3.`local.settings.json` or App Settings blade
204
+
3.`local.settings.json` or App Settings blade on Azure
164
205
165
206
166
207
### `host.json` ###
@@ -172,7 +213,7 @@ Although it has not been officially accepted to be a part of `host.json`, the Op
172
213
...
173
214
"openApi": {
174
215
"info": {
175
-
"version": "3.0.0",
216
+
"version": "1.0.0",
176
217
"title": "Open API Sample on Azure Functions",
177
218
"description": "A sample API that runs on Azure Functions 3.x using Open API specification - from **host. json**.",
*`OpenApi__ApiKey`: API Key of the endpoint that renders the Open API document.
233
274
234
-
> **NOTE**: In order to deploy Azure Functions v1 to Azure, the `AzureWebJobsScriptRoot`**MUST** be specified in the app settings section; otherwise it will throw an error that can't find `host.json`. Local debugging is fine, though. For more details, please visit [this page](https://docs.microsoft.com/bs-latn-ba/azure/azure-functions/functions-app-settings#azurewebjobsscriptroot).
275
+
> **NOTE**: In order to deploy Azure Functions v1 to Azure, the `AzureWebJobsScriptRoot`**MUST** be specified in the app settings section; otherwise it will throw an error that can't find `host.json`. Local debugging is fine, though. For more details, please visit [this page](https://docs.microsoft.com/azure/azure-functions/functions-app-settings#azurewebjobsscriptroot?WT.mc_id=azfuncextension-github-juyoo).
0 commit comments