Skip to content

senacor/azure-function-middleware-openapi-generator

Repository files navigation

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:

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<string, string>
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

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published