161
Views
4
Comments
Solved
[SwaggerProxy] Import swagger file with Service Studio 11.0.412.0 and nothing happens
Question
Forge component by João Rosado
4
Published on 15 Jun 2017

This does not appear to be a bug with SwaggerProxy, but I'm hoping maybe someone here can help...

I'm trying to consume the Stripe REST API, their swagger 2.0 file is here:
https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec2.json

I used SwaggerProxy to get a link that is swagger 2.0 compliant (i.e., the where file name is swagger.json), but when I try to consume the API methods now, no methods are ultimately added. There are no exceptions thrown, it just does nothing.

Any ideas what might be causing this?

Staff
Rank: #28
Solution

Hi Kirk,


The problem is related to the "expand" parameter in some of the methods. The type of the parameter is "array" but does not have any item types. Service Studio is not expecting that to be valid.

You can use the Swagger Proxy to customize it and add the necessary element.


For example in the GetAccountBankAccountsId operation it has:

{
            "description": "Specifies which fields in the response should be expanded.",
            "in": "query",
            "name": "expand",
            "required": false,
            "type": "array"
          }

and it should be:

{
            "description": "Specifies which fields in the response should be expanded.",
            "in": "query",
            "name": "expand",
            "required": false,
            "items": {
                    "type": "string"
            },
            "type": "array"
          }


Just replace all the 

            "required": false,
            "type": "array"

by

            "required": false,
            "items": {
                    "type": "string"
            },
            "type": "array"


With it was able to import it correctly:


Attaching the modified file for your comfort.


Regards,

João Rosado

stripe.txt

mvp_badge
MVP
Rank: #6

Hi Kirk.

That's not a bug in SwaggerProxy. Service Studio is crashing when trying to import that swagger file. The reason why you don't see any crash is that Service Studio silences repeated crashes (you probably experienced the crash on your first attempt to import the swagger).

Can you open a support case?

Staff
Rank: #28
Solution

Hi Kirk,


The problem is related to the "expand" parameter in some of the methods. The type of the parameter is "array" but does not have any item types. Service Studio is not expecting that to be valid.

You can use the Swagger Proxy to customize it and add the necessary element.


For example in the GetAccountBankAccountsId operation it has:

{
            "description": "Specifies which fields in the response should be expanded.",
            "in": "query",
            "name": "expand",
            "required": false,
            "type": "array"
          }

and it should be:

{
            "description": "Specifies which fields in the response should be expanded.",
            "in": "query",
            "name": "expand",
            "required": false,
            "items": {
                    "type": "string"
            },
            "type": "array"
          }


Just replace all the 

            "required": false,
            "type": "array"

by

            "required": false,
            "items": {
                    "type": "string"
            },
            "type": "array"


With it was able to import it correctly:


Attaching the modified file for your comfort.


Regards,

João Rosado

stripe.txt

Rank: #77567

Hi Kirk,

How did you go with this? I have tried following the steps above and seem to be importing the file correctly, however the stripe API doesn't accept application/json requests, it only accepts form-encoded.

Did you find a way to implement the openAPI spec?

Thanks,

Tom