react-openapi-client icon indicating copy to clipboard operation
react-openapi-client copied to clipboard

Retry When Init Fails

Open mwaeckerlin opened this issue 3 years ago • 0 comments

When the client instantiates the server offline, connection will never be established. Currently, in the code you catch the error, but do nothing with it. It would be nice, if that would update automatically when going online.

Therefore, I suggest to add a timer with a retry timer given in the properties (with some meaningful default, e.g. 5000ms). It could retry not only on initSyng (when reading the JSON definition), but also if a request fails.

e.g.

const App = () => (
  <OpenAPIProvider retry="5000" definition="http://petstore.swagger.io:8080/api/v3/openapi.json">
    <PetDetails id={1} />
  </OpenAPIProvider>
)

mwaeckerlin avatar Sep 16 '22 07:09 mwaeckerlin