How to setup Swagger for PowerApps correctly?

大城市里の小女人 提交于 2020-03-05 02:11:08

问题


This is my Azure function I want to connect to my PowerApps

        [FunctionName("ConvertMe")]
    public static IActionResult RunAsync
        ([HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req, ILogger log)
    {
        log.LogInformation($"Received a Request");
        ConvertMe Converter = new ConvertMe();

        string test1 = req.Query["image1"];
        string test2 = req.Query["image2"];


        MagickImage _Main = new MagickImage(Convert.FromBase64String(test1), MagickFormat.Png);
        MagickImage _Overlay = new MagickImage(Convert.FromBase64String(test2), MagickFormat.Png);

        using (MemoryStream memory = new MemoryStream())
        {
            Converter.ComebineBitmap(_Main, _Overlay).Write(memory, MagickFormat.Png);
            memory.Position = 0;
            return new FileContentResult(memory.ToArray(),"image/png");
        }

    }

Its already working on local but I want to use it in PowerApps. How do I get my return value to Swagger ?

My current swagger file

    {
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "MyAzureFunction"
  },
  "host": "xxx",
  "paths": {
    "/api/ConvertMe": {
      "get": {
        "description": "Calls my azure function over https",
        "operationId": "ConvertMe",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "description": "code",
            "default": "code",
            "type": "string"
          },
          {
            "name": "image1",
            "in": "query",
            "required": true,
            "type": "string"
          },     
          {
            "name": "image2",
            "in": "query",
            "required": true,
            "type": "string"
          },

        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "schema": {
              "title": "The response of the api.",
              "type": "string"
            }
          }
        }
      }
    }
  }
}

Ive never worked with swagger but ive already found out, the best is to work with base64 string.


回答1:


Microsoft has a tutorial for creating an OpenAPI definition from a server-less API. If you follow the steps laid out you will eventually get to the Download the OpenAPI definition step, which is what you can use to import into powerapps to make your custom connector.



来源:https://stackoverflow.com/questions/60229963/how-to-setup-swagger-for-powerapps-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!