openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Node API: allow retry/timeout functionality

Open abhay-ramesh opened this issue 1 year ago • 2 comments

Description

My backend server has a cold start and have added a generation of sdk in monorepo and on every pnpm dev of the monorepo it fails cause it cant fetch the json, can we have control on the timeout or have retryFor

import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
  name: "abcSDK",
  input:
    "https://example.com/openapi.json",
  output: "src",
  format: "prettier",
  timeout: 300,    // New Field
  retryFor: 3,        // New Field
});

OpenAPI specification (optional)

No response

Configuration

import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
  name: "abcSDK",
  input:
    "https://example.com/openapi.json",
  output: "src",
  format: "prettier",
  timeout: 300,    // New Field
  retryFor: 3,        // New Field
});

System information (optional)

No response

abhay-ramesh avatar May 07 '24 06:05 abhay-ramesh

https://github.com/hey-api/openapi-ts/blob/04f31ff45ac382e4cb464f77408826f904dc004d/packages/openapi-ts/src/utils/getOpenApiSpec.ts#L14

This File Might have some way to fix is what I guess, not sure

abhay-ramesh avatar May 07 '24 06:05 abhay-ramesh

Hey @abhay-ramesh, while I see the problem, this really isn't a bug, but a feature request. I'll need to think about this, but definitely wouldn't want to extend the API surface to accommodate this feature. It sounds like you could achieve this using Node API? I haven't tested it yet so can't tell you whether it's possible today, but that's where you could implement a timeout/retry however you like

mrlubos avatar May 07 '24 12:05 mrlubos