[SwaggerProxy] Import swagger file with Service Studio 11.0.412.0 and nothing happens

Forge Component
(4)
Published on 2017-06-15 by leonardo.fernandes
4 votes
Published on 2017-06-15 by leonardo.fernandes

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?

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?

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

Solution

João Rosado wrote:

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


Thanks João!