How to create response schema in exported swagger json from API in Azure API Management Service?

370 Views Asked by At
  • I have created API endpoints in Azure API management service and exported it as swagger.json file.
  • The export is to be consumed to create Connector in PowerApps.
  • Swagger file from API export contains response example which I entered manually in API endpoint definition.
  • Connector imports all the requests bodies correctly but fails to load sample response body.

My ultimate goal is to added sample response body to the connector's action automatically. I do not want to re-enter sample response body manually in the connector.

Endpoint schema from APIM (exported swagger.json file):

"/Patient/{id}": {
        "get": {
            "description": "/Patient/{id} - GET",
            "operationId": "get-patient-id",
            "summary": "/Patient/{id} - GET",
            "parameters": [{
                "name": "id",
                "in": "path",
                "description": "id of resource",
                "required": true,
                "type": "string"
            }],
            "produces": [
                "application/json"
            ],
            "responses": {
                "200": {
                    "description": "Success",
                    "example": {
                        "application/json": {
                            "resourceType": "Patient",
                            "id": "53",
                            "gender": "female",
                            "birthDate": "1989-07-30"
                        }
                    }
                }
            }
        }
    }

Endpoint schema from another Powerapps custom connector (swagger export):

"/Patient/{id}": {
  "get": {
    "operationId": "get-patient-id",
    "summary": "/Patient/{id} - GET",
    "parameters": [
      {
        "name": "id",
        "in": "path",
        "description": "id of resource",
        "required": true,
        "type": "string"
      }
    ],
    "responses": {
      "200": {
        "description": "Success",
        "schema": {
          "type": "object",
          "properties": {
            "resourceType": {
              "type": "string",
              "description": "resourceType"
            },
            "id": {
              "type": "string",
              "description": "id"
            },
            "gender": {
              "type": "string",
              "description": "gender"
            },
            "birthDate": {
              "type": "string",
              "description": "birthDate"
            }
          }
        }
      }
    }
  }
0

There are 0 best solutions below