This generates Open API document through command-line without having to run the Azure Functions instance. The more details around this CLI can be found on this blog post.
NOTE: This CLI supports both Open API 2.0 (aka Swagger) and Open API 3.0.1 spec.
- In order to read JSON configuration on Azure Functions 1.x, these extensions have copied the source code of Microsoft.Extensions.Configuration.Json to make use of Newtonsoft.Json 9.0.1 under the MIT License.
While using this CLI, if you find any issue, please raise a ticket on the Issue page.
The CLI is available for download at GitHub. It's always tagged with cli-<version>
. Download the latest version of CLI.
- For Azure Functions v1
- Windows only:
azfuncopenapi-v<version>-net461-win-x64.zip
- Windows only:
- For Azure Functions v2 or later
- Linux:
azfuncopenapi-v<version>-netcoreapp3.1-linux-x64.zip
- MacOS:
azfuncopenapi-v<version>-netcoreapp3.1-osx-x64.zip
- Windows:
azfuncopenapi-v<version>-netcoreapp3.1-win-x64.zip
- Linux:
Once you have an Azure Functions instance with Azure Functions Open API extension enabled, then you are ready to run this CLI.
For Windows:
# PowerShell Console
azfuncopenapi `
--project <PROJECT_PATH> `
--configuration Debug `
--target netcoreapp2.1 `
--version v2 `
--format json `
--output output `
--console false
For Linux/MacOS
# Bash
./azfuncopenapi \
--project <PROJECT_PATH> \
--configuration Debug \
--target netcoreapp2.1 \
--version v2 \
--format json \
--output output \
--console false
Here are options:
-p|--project
: Project path. It can be a fully qualified project path including.csproj
or project directory. Default is the current directory.-c|--configuration
: Configuration value. It can be eitherDebug
,Release
or something else. Default isDebug
.-t|--target
: Target framework. It should benet4x
for Azure Functions v1,netcoreapp2.x
for Azure Functions v2, andnetcoreapp3.x
for Azure Functions v3. Default isnetcoreapp2.1
.-v|--version
: Open API spec version. It should be eitherv2
orv3
. Default isv2
.-f|--format
: Open API document format. It should be eitherjson
oryaml
. Default isjson
.-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 isoutput
.--console
: Value indicating whether to display the generated document to console or not. Default isfalse
.
- Distribution through a npm package.
- Project boilerplate generation, if an Open API doc is provided.