A new feature (preview) in Azure Functions is API Definition. This feature allows you to use the OpenAPI specification (aka Swagger) to document the functionality of your functions and/or endpoints.

Checkout John Papa & I talk about using Swagger for ASP.NET Core on Pluralsight in Play by Play - Understanding API Functionality Through Swagger

The documentation and a walkthrough of Creating OpenAPI 2.0 (Swagger) Metadata for a Function App (Preview) are available on docs.microsoft.com.

Testing your function

After you have your api defined, copy the endpoint in the API Definition URL box to use to import into Postman.

Open Postman, click the Import button.

Select Import from Link and paste your definition endpoint.

Postman reads the imported definition file and creates an entry in the collections panel.

In the image above, the /hero endpoint with the summary "Get Hero Name" was created from the Swagger definition snippet:

    "paths": {
        "/hero": {
            "get": {
                "summary": "Get Hero Name",
                "description": "Generates a Super Hero name for a person's First and Last Name.\n",
                "parameters": [
                    {
                        "name": "first",
                        "in": "query",
                        "description": "First Name",
                        "required": true,
                        "type": "string",
                        "format": "string"
                    },
                    {
                        "name": "last",
                        "in": "query",
                        "description": "Last Name.",
                        "required": true,
                        "type": "string",
                        "format": "string"
                    }
                ],

Postman also auto recognizes when creating a new tab for a test, the METHOD is a GET as noted above in the snippet and the url contains the {first} and {last} query parameters as defined.

I will be exploring more of the API Definition feature in Azure Functions as it continues to evolve. Be sure to submit any feedback on GitHub for Azure-Functions because it is open source.

Checkout John Papa's post on Configuring Azure Functions: Intellisense via JSON Schemas.

 ·  Azure Docs  ·  Free Azure Account  · 
Try Azure Functions Playground