Hello,
Help please.
I was just walking thourgh using the custom API in PowerApps. When I try to connect to an API endpoint using the trial swagger file that I've saved from here (http://petstore.swagger.io/v2/swagger.json) PowerApps fail with following error:
An error occurred while converting swagger file to WADL file. Error: 'Operation id "addPet" must specify either a default response or a 200-series response. Any other responses in the swagger is not supported by PowerApps client at JSON path paths./pet.post'. Your API may not work with apps.
Why is it so, although the swagger file I am uploading is one of the swagger.io provided? Otherwise, I would have guessed if swagger was not properly built.
Solved! Go to Solution.
To unblock yourself, you can manually modify the swagger to add success responses to those operations that do not already have a 2xx response specified.
e.g., for the operation 'addPet', change the "responses" to:
"responses": {
"200": { "description": "Success." },
"405": { "description": "Invalid input" }
},
Also, there are a couple other things this swagger is using which is not currently supported by PowerApps. But these are only limitations of PowerApps, not invalid Swagger.
- Query parameters of type array are not supported. This affects operations: findPetsByTags and findPetsByStatus. To fix this, I just made the type of these parameters "string" and removed the extra properties.
Per the Swagger spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#responsesObject
The Responses Object MUST contain at least one response code, and it SHOULD be the response for a successful operation call.
But looks like their example isn’t actually to spec:
Here’s what that swagger operation looks like:
"post": {
"tags": [ "pet" ],
"summary": "Add a new pet to the store",
"description": "",
"operationId": "addPet",
"consumes": [ "application/json", "application/xml" ],
"produces": [ "application/xml", "application/json" ],
"parameters": [
{
"in": "body",
"name": "body",
"description": "Pet object that needs to be added to the store",
"required": true,
"schema": { "$ref": "#/definitions/Pet" }
}
],
"responses": { "405": { "description": "Invalid input" } },
"security": [ { "petstore_auth": [ "write:pets", "read:pets" ] } ]
},
405 is an error response. This operation doesn’t specify what a successful response is: e.g. any responses in the 2xx range.
So, unfortunately, it looks like their sample Swagger is invalid.
To unblock yourself, you can manually modify the swagger to add success responses to those operations that do not already have a 2xx response specified.
e.g., for the operation 'addPet', change the "responses" to:
"responses": {
"200": { "description": "Success." },
"405": { "description": "Invalid input" }
},
Also, there are a couple other things this swagger is using which is not currently supported by PowerApps. But these are only limitations of PowerApps, not invalid Swagger.
- Query parameters of type array are not supported. This affects operations: findPetsByTags and findPetsByStatus. To fix this, I just made the type of these parameters "string" and removed the extra properties.
Well, I've not really tried your proposed solution. Relying on you, I've marked it as answer.
I've just had a look at the PetStore swagger file with the latest version of PowerApps and it looks like Arrays are still not supported.
Any idea if this is on the roadmap?
User | Count |
---|---|
168 | |
96 | |
77 | |
72 | |
59 |
User | Count |
---|---|
210 | |
166 | |
97 | |
94 | |
78 |