stripe / openapi

An OpenAPI specification for the Stripe API.
MIT License
394 stars 123 forks source link

Spec3.json with Swagger UI - Out of Memory error #98

Closed Cedric-Magnan closed 1 year ago

Cedric-Magnan commented 1 year ago

In order to get a clear picture of what I can do with Stripe, I have been trying to deploy the Swagger UI with Stripe specifications from version 3 (spec3.json) using the docker image swaggerapi/swagger-ui.

curl "https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json" > openapi.json
docker run -p 8000:8080 -e SWAGGER_JSON=/data/openapi.json -v $(pwd)/openapi.json:/data/openapi.json swaggerapi/swagger-ui

The documentation seems to work at first, but then, whenever I try to open the specifications for a specific endpoint, it never opens completely and just keeps on loading forever. Here is an example below :

image

After some time, Chrome returns an Out of Memory error.

Do you have any documentation on how to deploy the Swagger UI with this project or can you clarify if this is supported or not ?

richardm-stripe commented 1 year ago

Hello @Cedric-Magnan, thank you for writing in.

I suspect that swagger-ui is struggling with the size of the Stripe OpenAPI spec. I would report the issue to them.

I can play around with swagger-ui for awhile to see if there's a simple fix, but if not I expect there's nothing we can do on our end short of finding a way to split Stripe's OpenAPI spec into smaller parts, which is something we've considered in the past but is unlikely to happen soon.

We don't officially support swagger-ui. We do provide (and officially support) a Postman Collection. We also provide the Stripe CLI, a tool to help you interactively explore the Stripe API from the command-line, and the Stripe Shell, a similar tool that helps you explore from the context of the Stripe docs.

Cedric-Magnan commented 1 year ago

Hello @richardm-stripe,

Thanks for the useful informations ! I will close this issue since nothing can be done on this repository.

richardm-stripe commented 1 year ago

I spent a short amount of time investigating this. I was able to reproduce the issue locally. Interestingly, I found the OOM no longer occured if I did

cat openapi/spec3.json | sed 's/\/components\/schemas\/[^"]*/\/components\/schemas\/account/g' > smallspec.json

this is just a really dumb attempt to try and narrow down the problem by producer a simpler (but completely invalid) spec.

So this means that it might not be the size of spec3.json that's breaking swagger-ui, it might have something to do instead with some sort of circular reference. In any case I still think ultimately the fix probably needs to come from Swagger but wanted to log my findings.