Skip to content

No Timeout Configuration for readLocation/read Method #2156

Open
@sohitkumar

Description

I am facing challenges with the readLocation method in swagger-parser. When attempting to load an OpenAPI specification from a remote URL that is not reachable, the method takes around 2 minutes before it throws an exception and reaches the catch block.

This behavior seems to stem from the lack of explicit connection and read timeout configurations within the swagger-parser library.

Use Case
In scenarios where the remote URL is invalid, unreachable, or timing out, I would expect the parser to throw an error immediately or within a reasonable timeout period. However, currently, the method appears to rely on the underlying HTTP client's default timeout settings (which can be quite high, e.g., 120 seconds), causing unnecessary delays in the application flow.

Expected Behavior
Provide a way to configure:

Connection Timeout: Maximum time to establish a connection to the remote server.
Read Timeout: Maximum time to wait for a response after the connection is established.

For example, I would like to set these timeouts explicitly when using the readLocation method:

SwaggerParseResult parseResult = parser.readLocation( url, null, null, connectionTimeout = 3000, // Connection timeout (in milliseconds) readTimeout = 5000 // Read timeout (in milliseconds) );

Is there best workarounds for this ?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions