Creating a swagger definition for an Azure Logic Apps Http Request endpoint

2016, Aug 03    

If you’ve created a Logic App with a HTTP Request trigger, then next logical thing to do is expose it for consumption (Like in Azure API Management).
Swagger is now the defacto way of describing API’s, and it makes sense that you’d want to create one for your logic app. I’m sure this will make it in there as a feature soon, but for the moment you need to roll your own.

The LogicAppsRequestSchema is exactly the same Json schema that you used in the HTTP Request Trigger action, so keep that handy. The text in bold are the areas you need to replace with your own.

I find that http://editor.swagger.io is the best tool for creating the Swagger files.
The validation is great (although it doesn’t like the default values for the parameters, which as far as i can gather are valid).

{<br /> "swagger": "2.0",<br /> "info": {<br /> "title": "<strong>Friendly name for your logic app</strong>",<br /> "description": "<strong>Some kind of description about what it does</strong>",<br /> "version": "1.0.0"<br /> },<br /> "host": "<strong>aprodinstance.anazureregion</strong>.logic.azure.com:443",<br /> "schemes": [<br /> "https"<br /> ],<br /> "basePath": "/workflows/<strong>yourworkflowid</strong>/triggers/manual",<br /> "produces": [<br /> "application/json"<br /> ],<br /> "paths": {<br /> "/run": {<br /> "post": {<br /> "consumes": [<br /> "application/json"<br /> ],<br /> "operationId": "Friendly text",<br /> "summary": "Friendly text",<br /> "description": "Friendly text",<br /> "parameters": [<br /> {<br /> "name": "api-version",<br /> "in": "query",<br /> "description": "api-version",<br /> "required": true,<br /> "default": "2016-06-01",<br /> "type": "string"<br /> },<br /> {<br /> "name": "sp",<br /> "in": "query",<br /> "description": "sp",<br /> "required": true,<br /> "default": "%2Ftriggers%2Fmanual%2Frun",<br /> "type": "string"<br /> },<br /> {<br /> "name": "sv",<br /> "in": "query",<br /> "description": "sv",<br /> "required": true,<br /> "default": "1.0",<br /> "type": "string"<br /> },<br /> {<br /> "name": "sig",<br /> "in": "query",<br /> "description": "sig",<br /> "required": true,<br /> "default": "<strong>thesignaturepartinyourlogicapphttpurl</strong>",<br /> "type": "string"<br /> },<br /> {<br /> "name": "body",<br /> "in": "body",<br /> "description": "The json you want to submit",<br /> "required": true,<br /> "schema": {<br /> "$ref": "#/definitions/LogicAppsRequestSchema"<br /> }<br /> }<br /> ],<br /> "responses": {<br /> "200": {<br /> "description": "Logic Apps response",<br /> "schema": {<br /> "$ref": "#/definitions/LogicAppsResponse"<br /> }<br /> }<br /> }<br /> }<br /> }<br /> },<br /> "definitions": {<br /> <strong>"LogicAppsRequestSchema":<br /> {<br /> "type": "object",<br /> "required": [<br /> "Header",<br /> "StartOfDuty"<br /> ],<br /> "properties": {<br /> "Obj1": {<br /> "properties": {<br /> "Prop1": {<br /> "type": "string"<br /> }<br /> "required": ["rop1"],<br /> "type": "object"<br /> },<br /> "Obj2": {<br /> "properties": {<br /> "Prop1": {<br /> "type": "string"<br /> }<br /> "required": ["Prop1"],<br /> "type": "object"<br /> }<br /> }<br /> }<br /> </strong>,<br /> "LogicAppsResponse": {<br /> "type": "object",<br /> "properties": {<br /> "success": {<br /> "type": "boolean",<br /> "description": "Just a simple response property. You could template return objects/ error messages etc."<br /> }<br /> }<br /> }<br /> }<br /> }