OpenAPI Generator for @senacor/azure-function-middleware
npm install @senacor/azure-function-middleware-openapi-generatorThis tool generates an OpenAPI definition for an Azure Function App built with
the @senacor/azure-function-middleware.
``bash`
npm install @senacor/azure-function-middleware-openapi-generator --save-dev
Create a configuration file openapi-generation.config.json in the project's root directory:
`json`
{
"apiDefinitions": [
{
"title": "My API",
"outputFile": "api.yaml"
}
]
}
See chapter configuration for more options.
Run the OpenAPI generator with:
`bash`
npx @senacor/azure-function-middleware-openapi-generator
The configuration is stored in the file openapi-generation.config.json. Every API is described by an ApiDefinitionConfiguration object stored in theapiDefinitions array.
Parameters for ApiDefinitionConfiguration:
| Name | Type | Required | Description |
|----------------------------|------------------------|----------|-------------------------------------------------------------------------------|
| title | string | x | Title of the API definition |
| description | string | | Description for the API definition |
| servers | ServerObject[] | | Details for the server section of the OpenAPI definition |
| servers[].url | string | x | |
| servers[].description | string | | |
| servers[].variables | Record
| outputFile | string | x | Name of the generated file. Supported file extensions are .json and .yaml |
| functionNameRegexToInclude | string[] | | List of regex patters to include http functions based on their name |
| functionNameRegexToExclude | string[] | | List of regex patters to exclude http functions based on their name |
| excludeRequestBody | boolean | | Exclude the request body from the generated API definition |
| excludeResponseBody | boolean | | Exclude the response body from the generated API definition |
Logic to include / exclude http functions:
* If functionNameRegexToInclude and functionNameRegexToExclude are not specified all functions are used.functionNameRegexToExclude
* Otherwise:
* If is defined and the http function name matches some pattern from functionNameRegexToExclude, then the http function will be excluded from the api definition.functionNameRegexToInclude
* If is defined and the http function name matches some pattern from functionNameRegexToInclude, then the http function will be included into the api definition.
is used
* Request body schema if requestBodyValidation is used
* Response body schema if responseBodyValidation` is used