0.0.1 • Published 12 months ago

@senacor/azure-function-middleware-openapi-generator v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

OpenAPI Generator for Azure Function Middleware

This tool generates an OpenAPI definition for an Azure Function App built with the @senacor/azure-function-middleware.

Installation

npm install @senacor/azure-function-middleware-openapi-generator --save-dev

Usage

Create a configuration file openapi-generation.config.json in the project's root directory:

{
  "apiDefinitions": [
    {
      "title": "My API",
      "outputFile": "api.yaml"
    }
  ]
}

See chapter configuration for more options.

Run the OpenAPI generator with:

npx @senacor/azure-function-middleware-openapi-generator

Configuration

The configuration is stored in the file openapi-generation.config.json. Every API is described by an ApiDefinitionConfiguration object stored in the apiDefinitions array.

Parameters for ApiDefinitionConfiguration:

NameTypeRequiredDescription
titlestringxTitle of the API definition
descriptionstringDescription for the API definition
serversServerObject[]Details for the server section of the OpenAPI definition
servers[].urlstringx
servers[].descriptionstring
servers[].variablesRecord<string, string>
outputFilestringxName of the generated file. Supported file extensions are .json and .yaml
functionNameRegexToIncludestring[]List of regex patters to include http functions based on their name
functionNameRegexToExcludestring[]List of regex patters to exclude http functions based on their name

Logic to include / exclude http functions:

  • If functionNameRegexToInclude and functionNameRegexToExclude are not specified all functions are used.
  • Otherwise:
    • If the http function name matches some pattern from functionNameRegexToExclude, then the http function will be excluded from the api definition.
    • If the http function name matches some pattern from functionNameRegexToInclude, then the http function will be included into the api definition.

Supported Features

  • URL path parameters
  • URL query parameters if requestQueryParamsValidation is used
  • Request body schema if requestBodyValidation is used
  • Response body schema if responseBodyValidation is used
  • Security schemas for bearer and function key authentication