326
Views
4
Comments
Solved
[SwaggerProxy] Import swagger file with Service Studio 11.0.412.0 and nothing happens
Question
swaggerproxy
Web icon
Forge asset by João Rosado

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?

2012-03-16 12-21-09
João Rosado
Staff
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
UserImage.jpg
Kirk Sealls

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!

2019-07-08 11-04-35
Leonardo Fernandes
 
MVP

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?

2012-03-16 12-21-09
João Rosado
Staff
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
UserImage.jpg
Kirk Sealls

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!

UserImage.jpg
Cozy App

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

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.