diff --git a/test/client/timeouttest/TimeoutTestClient/.openapi-generator-ignore b/test/client/timeouttest/TimeoutTestClient/.openapi-generator-ignore
new file mode 100644
index 0000000..7484ee5
--- /dev/null
+++ b/test/client/timeouttest/TimeoutTestClient/.openapi-generator-ignore
@@ -0,0 +1,23 @@
+# OpenAPI Generator Ignore
+# Generated by openapi-generator https://github.com/openapitools/openapi-generator
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/test/client/timeouttest/TimeoutTestClient/.openapi-generator/FILES b/test/client/timeouttest/TimeoutTestClient/.openapi-generator/FILES
new file mode 100644
index 0000000..cbc004f
--- /dev/null
+++ b/test/client/timeouttest/TimeoutTestClient/.openapi-generator/FILES
@@ -0,0 +1,8 @@
+.openapi-generator-ignore
+README.md
+docs/DefaultApi.md
+docs/DelayresponseGet200Response.md
+src/TimeoutTestClient.jl
+src/apis/api_DefaultApi.jl
+src/modelincludes.jl
+src/models/model_DelayresponseGet200Response.jl
diff --git a/test/client/timeouttest/TimeoutTestClient/.openapi-generator/VERSION b/test/client/timeouttest/TimeoutTestClient/.openapi-generator/VERSION
new file mode 100644
index 0000000..4b49d9b
--- /dev/null
+++ b/test/client/timeouttest/TimeoutTestClient/.openapi-generator/VERSION
@@ -0,0 +1 @@
+7.2.0
\ No newline at end of file
diff --git a/test/client/timeouttest/TimeoutTestClient/README.md b/test/client/timeouttest/TimeoutTestClient/README.md
new file mode 100644
index 0000000..4f1e662
--- /dev/null
+++ b/test/client/timeouttest/TimeoutTestClient/README.md
@@ -0,0 +1,39 @@
+# Julia API client for TimeoutTestClient
+
+No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+
+## Overview
+This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
+
+- API version: 1.0.0
+- Build package: org.openapitools.codegen.languages.JuliaClientCodegen
+
+
+## Installation
+Place the Julia files generated under the `src` folder in your Julia project. Include TimeoutTestClient.jl in the project code.
+It would include the module named TimeoutTestClient.
+
+Documentation is generated as markdown files under the `docs` folder. You can include them in your project documentation.
+Documentation is also embedded in Julia which can be used with a Julia specific documentation generator.
+
+## API Endpoints
+
+Class | Method
+------------ | -------------
+*DefaultApi* | [**delayresponse_get**](docs/DefaultApi.md#delayresponse_get)
**GET** /delayresponse
Delay Response Endpoint
+
+
+## Models
+
+ - [DelayresponseGet200Response](docs/DelayresponseGet200Response.md)
+
+
+
+## Authorization
+Endpoints do not require authorization.
+
+
+## Author
+
+
+
diff --git a/test/client/timeouttest/TimeoutTestClient/docs/DefaultApi.md b/test/client/timeouttest/TimeoutTestClient/docs/DefaultApi.md
new file mode 100644
index 0000000..74c4a60
--- /dev/null
+++ b/test/client/timeouttest/TimeoutTestClient/docs/DefaultApi.md
@@ -0,0 +1,37 @@
+# DefaultApi
+
+All URIs are relative to *http://localhost*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**delayresponse_get**](DefaultApi.md#delayresponse_get) | **GET** /delayresponse | Delay Response Endpoint
+
+
+# **delayresponse_get**
+> delayresponse_get(_api::DefaultApi, delay_seconds::Int64; _mediaType=nothing) -> DelayresponseGet200Response, OpenAPI.Clients.ApiResponse
+> delayresponse_get(_api::DefaultApi, response_stream::Channel, delay_seconds::Int64; _mediaType=nothing) -> Channel{ DelayresponseGet200Response }, OpenAPI.Clients.ApiResponse
+
+Delay Response Endpoint
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **_api** | **DefaultApi** | API context |
+**delay_seconds** | **Int64**| Number of seconds to delay the response | [default to nothing]
+
+### Return type
+
+[**DelayresponseGet200Response**](DelayresponseGet200Response.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
+
diff --git a/test/client/timeouttest/TimeoutTestClient/docs/DelayresponseGet200Response.md b/test/client/timeouttest/TimeoutTestClient/docs/DelayresponseGet200Response.md
new file mode 100644
index 0000000..b47de34
--- /dev/null
+++ b/test/client/timeouttest/TimeoutTestClient/docs/DelayresponseGet200Response.md
@@ -0,0 +1,12 @@
+# DelayresponseGet200Response
+
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**delay_seconds** | **String** | | [optional] [default to nothing]
+
+
+[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/test/client/timeouttest/TimeoutTestClient/src/TimeoutTestClient.jl b/test/client/timeouttest/TimeoutTestClient/src/TimeoutTestClient.jl
new file mode 100644
index 0000000..936725b
--- /dev/null
+++ b/test/client/timeouttest/TimeoutTestClient/src/TimeoutTestClient.jl
@@ -0,0 +1,16 @@
+# This file was generated by the Julia OpenAPI Code Generator
+# Do not modify this file directly. Modify the OpenAPI specification instead.
+
+module TimeoutTestClient
+
+using Dates, TimeZones
+using OpenAPI
+using OpenAPI.Clients
+
+const API_VERSION = "1.0.0"
+
+include("modelincludes.jl")
+
+include("apis/api_DefaultApi.jl")
+
+end # module TimeoutTestClient
diff --git a/test/client/timeouttest/TimeoutTestClient/src/apis/api_DefaultApi.jl b/test/client/timeouttest/TimeoutTestClient/src/apis/api_DefaultApi.jl
new file mode 100644
index 0000000..3cf0a93
--- /dev/null
+++ b/test/client/timeouttest/TimeoutTestClient/src/apis/api_DefaultApi.jl
@@ -0,0 +1,45 @@
+# This file was generated by the Julia OpenAPI Code Generator
+# Do not modify this file directly. Modify the OpenAPI specification instead.
+
+struct DefaultApi <: OpenAPI.APIClientImpl
+ client::OpenAPI.Clients.Client
+end
+
+"""
+The default API base path for APIs in `DefaultApi`.
+This can be used to construct the `OpenAPI.Clients.Client` instance.
+"""
+basepath(::Type{ DefaultApi }) = "http://localhost"
+
+const _returntypes_delayresponse_get_DefaultApi = Dict{Regex,Type}(
+ Regex("^" * replace("200", "x"=>".") * "\$") => DelayresponseGet200Response,
+)
+
+function _oacinternal_delayresponse_get(_api::DefaultApi, delay_seconds::Int64; _mediaType=nothing)
+ OpenAPI.validate_param("delay_seconds", "delayresponse_get", :minimum, delay_seconds, 0, false)
+
+ _ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_delayresponse_get_DefaultApi, "/delayresponse", [])
+ OpenAPI.Clients.set_param(_ctx.query, "delay_seconds", delay_seconds) # type Int64
+ OpenAPI.Clients.set_header_accept(_ctx, ["application/json", ])
+ OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType])
+ return _ctx
+end
+
+@doc raw"""Delay Response Endpoint
+
+Params:
+- delay_seconds::Int64 (required)
+
+Return: DelayresponseGet200Response, OpenAPI.Clients.ApiResponse
+"""
+function delayresponse_get(_api::DefaultApi, delay_seconds::Int64; _mediaType=nothing)
+ _ctx = _oacinternal_delayresponse_get(_api, delay_seconds; _mediaType=_mediaType)
+ return OpenAPI.Clients.exec(_ctx)
+end
+
+function delayresponse_get(_api::DefaultApi, response_stream::Channel, delay_seconds::Int64; _mediaType=nothing)
+ _ctx = _oacinternal_delayresponse_get(_api, delay_seconds; _mediaType=_mediaType)
+ return OpenAPI.Clients.exec(_ctx, response_stream)
+end
+
+export delayresponse_get
diff --git a/test/client/timeouttest/TimeoutTestClient/src/modelincludes.jl b/test/client/timeouttest/TimeoutTestClient/src/modelincludes.jl
new file mode 100644
index 0000000..af7c2e0
--- /dev/null
+++ b/test/client/timeouttest/TimeoutTestClient/src/modelincludes.jl
@@ -0,0 +1,4 @@
+# This file was generated by the Julia OpenAPI Code Generator
+# Do not modify this file directly. Modify the OpenAPI specification instead.
+
+include("models/model_DelayresponseGet200Response.jl")
diff --git a/test/client/timeouttest/TimeoutTestClient/src/models/model_DelayresponseGet200Response.jl b/test/client/timeouttest/TimeoutTestClient/src/models/model_DelayresponseGet200Response.jl
new file mode 100644
index 0000000..c700d17
--- /dev/null
+++ b/test/client/timeouttest/TimeoutTestClient/src/models/model_DelayresponseGet200Response.jl
@@ -0,0 +1,30 @@
+# This file was generated by the Julia OpenAPI Code Generator
+# Do not modify this file directly. Modify the OpenAPI specification instead.
+
+
+@doc raw"""_delayresponse_get_200_response
+
+ DelayresponseGet200Response(;
+ delay_seconds=nothing,
+ )
+
+ - delay_seconds::String
+"""
+Base.@kwdef mutable struct DelayresponseGet200Response <: OpenAPI.APIModel
+ delay_seconds::Union{Nothing, String} = nothing
+
+ function DelayresponseGet200Response(delay_seconds, )
+ OpenAPI.validate_property(DelayresponseGet200Response, Symbol("delay_seconds"), delay_seconds)
+ return new(delay_seconds, )
+ end
+end # type DelayresponseGet200Response
+
+const _property_types_DelayresponseGet200Response = Dict{Symbol,String}(Symbol("delay_seconds")=>"String", )
+OpenAPI.property_type(::Type{ DelayresponseGet200Response }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_DelayresponseGet200Response[name]))}
+
+function check_required(o::DelayresponseGet200Response)
+ true
+end
+
+function OpenAPI.validate_property(::Type{ DelayresponseGet200Response }, name::Symbol, val)
+end
diff --git a/test/client/timeouttest/generate.sh b/test/client/timeouttest/generate.sh
new file mode 100755
index 0000000..7291031
--- /dev/null
+++ b/test/client/timeouttest/generate.sh
@@ -0,0 +1,5 @@
+java -jar openapi-generator-cli.jar generate \
+ -i ../../specs/timeouttest.yaml \
+ -g julia-client \
+ -o TimeoutTestClient \
+ --additional-properties=packageName=TimeoutTestClient
diff --git a/test/client/timeouttest/runtests.jl b/test/client/timeouttest/runtests.jl
new file mode 100644
index 0000000..73a229b
--- /dev/null
+++ b/test/client/timeouttest/runtests.jl
@@ -0,0 +1,58 @@
+module TimeoutTests
+
+include(joinpath(@__DIR__, "TimeoutTestClient", "src", "TimeoutTestClient.jl"))
+using .TimeoutTestClient
+using Test
+using JSON
+using HTTP
+using OpenAPI
+using OpenAPI.Clients
+import OpenAPI.Clients: Client, with_timeout, ApiException
+
+const M = TimeoutTestClient
+const server = "http://127.0.0.1:8081"
+
+function test_normal_operation(client, delay_secs)
+ @info("timeout default, delay $delay_secs secs")
+ api = M.DefaultApi(client)
+ api_return, http_resp = delayresponse_get(api, delay_secs)
+ @test http_resp.status == 200
+ @test api_return.delay_seconds == string(delay_secs)
+end
+
+function test_timeout_operation(client, timeout_secs, delay_secs)
+ @info("timeout $timeout_secs secs, delay $delay_secs secs")
+ with_timeout(client, timeout_secs) do client
+ try
+ api = M.DefaultApi(client)
+ delayresponse_get(api, delay_secs)
+ error("Timeout not thrown")
+ catch ex
+ @test isa(ex, ApiException)
+ @test ex.status == 0
+ @test startswith(ex.reason, "Operation timed out")
+ end
+ end
+end
+
+function runtests()
+ @testset "timeout_tests" begin
+ @info("TimeoutTest")
+ client = Client(server)
+
+ test_normal_operation(client, 10)
+
+ for timeout_secs in (5, 120) # test different timeouts
+ delay_secs = timeout_secs + 60
+ test_timeout_operation(client, timeout_secs, delay_secs)
+
+ # but the client should still be usable
+ test_normal_operation(client, 10)
+ end
+
+ # also test a long delay in general (default libcurl timeout is 0)
+ test_normal_operation(client, 160)
+ end
+end
+
+end # module TimeoutTests
diff --git a/test/runtests.jl b/test/runtests.jl
index b6fe7bd..1e4ade5 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -6,6 +6,7 @@ include("modelgen/testmodelgen.jl")
include("client/runtests.jl")
include("client/allany/runtests.jl")
include("forms/forms_client.jl")
+include("client/timeouttest/runtests.jl")
@testset "OpenAPI" begin
@testset "ModelGen" begin
@@ -153,4 +154,28 @@ include("forms/forms_client.jl")
@testset "Helper Methods" begin
AllAnyTests.test_http_resp()
end
+
+ @testset "Timeout Handling" begin
+ ret = out = nothing
+ servers_running = true
+
+ try
+ if run_tests_with_servers
+ ret, out = run_server(joinpath(@__DIR__, "server", "timeouttest", "timeouttest_server.jl"))
+ servers_running &= wait_server(8081)
+ TimeoutTests.runtests()
+ else
+ servers_running = false
+ end
+ finally
+ if run_tests_with_servers && !servers_running
+ # we probably had an error starting the servers
+ out_str = isnothing(out) ? "" : String(take!(out))
+ @warn("Servers not running", ret=ret, out_str)
+ end
+ run_tests_with_servers && stop_server(8081, ret, out)
+ end
+ end
+ run_tests_with_servers && sleep(20) # avoid port conflicts
+
end
diff --git a/test/server/timeouttest/TimeoutTestServer/.openapi-generator-ignore b/test/server/timeouttest/TimeoutTestServer/.openapi-generator-ignore
new file mode 100644
index 0000000..7484ee5
--- /dev/null
+++ b/test/server/timeouttest/TimeoutTestServer/.openapi-generator-ignore
@@ -0,0 +1,23 @@
+# OpenAPI Generator Ignore
+# Generated by openapi-generator https://github.com/openapitools/openapi-generator
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/test/server/timeouttest/TimeoutTestServer/.openapi-generator/FILES b/test/server/timeouttest/TimeoutTestServer/.openapi-generator/FILES
new file mode 100644
index 0000000..ebea56a
--- /dev/null
+++ b/test/server/timeouttest/TimeoutTestServer/.openapi-generator/FILES
@@ -0,0 +1,8 @@
+.openapi-generator-ignore
+README.md
+docs/DefaultApi.md
+docs/DelayresponseGet200Response.md
+src/TimeoutTestServer.jl
+src/apis/api_DefaultApi.jl
+src/modelincludes.jl
+src/models/model_DelayresponseGet200Response.jl
diff --git a/test/server/timeouttest/TimeoutTestServer/.openapi-generator/VERSION b/test/server/timeouttest/TimeoutTestServer/.openapi-generator/VERSION
new file mode 100644
index 0000000..4b49d9b
--- /dev/null
+++ b/test/server/timeouttest/TimeoutTestServer/.openapi-generator/VERSION
@@ -0,0 +1 @@
+7.2.0
\ No newline at end of file
diff --git a/test/server/timeouttest/TimeoutTestServer/README.md b/test/server/timeouttest/TimeoutTestServer/README.md
new file mode 100644
index 0000000..ec09996
--- /dev/null
+++ b/test/server/timeouttest/TimeoutTestServer/README.md
@@ -0,0 +1,57 @@
+# Julia API server for TimeoutTestServer
+
+No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+
+## Overview
+This API server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
+
+- API version: 1.0.0
+- Build package: org.openapitools.codegen.languages.JuliaServerCodegen
+
+
+## Installation
+Place the Julia files generated under the `src` folder in your Julia project. Include TimeoutTestServer.jl in the project code.
+It would include the module named TimeoutTestServer.
+
+Implement the server methods as listed below. They are also documented with the TimeoutTestServer module.
+Launch a HTTP server with a router that has all handlers registered. A `register` method is provided in TimeoutTestServer module for convenience.
+
+```julia
+register(
+ router::HTTP.Router, # Router to register handlers in
+ impl; # Module that implements the server methods
+ path_prefix::String="", # Prefix to be applied to all paths
+ optional_middlewares... # Optional middlewares to be applied to all handlers
+)
+```
+
+Optional middlewares can be one or more of:
+- `init`: called before the request is processed
+- `pre_validation`: called after the request is parsed but before validation
+- `pre_invoke`: called after validation but before the handler is invoked
+- `post_invoke`: called after the handler is invoked but before the response is sent
+
+The order in which middlewares are invoked are:
+`init |> read |> pre_validation |> validate |> pre_invoke |> invoke |> post_invoke`
+
+
+## API Endpoints
+
+The following server methods must be implemented:
+
+Class | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+*DefaultApi* | [**delayresponse_get**](docs/DefaultApi.md#delayresponse_get) | **GET** /delayresponse | Delay Response Endpoint
+
+
+
+## Models
+
+ - [DelayresponseGet200Response](docs/DelayresponseGet200Response.md)
+
+
+
+## Author
+
+
+
diff --git a/test/server/timeouttest/TimeoutTestServer/docs/DefaultApi.md b/test/server/timeouttest/TimeoutTestServer/docs/DefaultApi.md
new file mode 100644
index 0000000..69d6a79
--- /dev/null
+++ b/test/server/timeouttest/TimeoutTestServer/docs/DefaultApi.md
@@ -0,0 +1,36 @@
+# DefaultApi
+
+All URIs are relative to *http://localhost*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**delayresponse_get**](DefaultApi.md#delayresponse_get) | **GET** /delayresponse | Delay Response Endpoint
+
+
+# **delayresponse_get**
+> delayresponse_get(req::HTTP.Request, delay_seconds::Int64;) -> DelayresponseGet200Response
+
+Delay Response Endpoint
+
+### Required Parameters
+
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------
+ **req** | **HTTP.Request** | The HTTP Request object |
+**delay_seconds** | **Int64**| Number of seconds to delay the response | [default to nothing]
+
+### Return type
+
+[**DelayresponseGet200Response**](DelayresponseGet200Response.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: application/json
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
diff --git a/test/server/timeouttest/TimeoutTestServer/docs/DelayresponseGet200Response.md b/test/server/timeouttest/TimeoutTestServer/docs/DelayresponseGet200Response.md
new file mode 100644
index 0000000..b47de34
--- /dev/null
+++ b/test/server/timeouttest/TimeoutTestServer/docs/DelayresponseGet200Response.md
@@ -0,0 +1,12 @@
+# DelayresponseGet200Response
+
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**delay_seconds** | **String** | | [optional] [default to nothing]
+
+
+[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)
+
+
diff --git a/test/server/timeouttest/TimeoutTestServer/src/TimeoutTestServer.jl b/test/server/timeouttest/TimeoutTestServer/src/TimeoutTestServer.jl
new file mode 100644
index 0000000..5e41ac3
--- /dev/null
+++ b/test/server/timeouttest/TimeoutTestServer/src/TimeoutTestServer.jl
@@ -0,0 +1,54 @@
+# This file was generated by the Julia OpenAPI Code Generator
+# Do not modify this file directly. Modify the OpenAPI specification instead.
+
+
+@doc raw"""
+Encapsulates generated server code for TimeoutTestServer
+
+The following server methods must be implemented:
+
+- **delayresponse_get**
+ - *invocation:* GET /delayresponse
+ - *signature:* delayresponse_get(req::HTTP.Request, delay_seconds::Int64;) -> DelayresponseGet200Response
+"""
+module TimeoutTestServer
+
+using HTTP
+using URIs
+using Dates
+using TimeZones
+using OpenAPI
+using OpenAPI.Servers
+
+const API_VERSION = "1.0.0"
+
+include("modelincludes.jl")
+
+include("apis/api_DefaultApi.jl")
+
+"""
+Register handlers for all APIs in this module in the supplied `Router` instance.
+
+Paramerets:
+- `router`: Router to register handlers in
+- `impl`: module that implements the server methods
+
+Optional parameters:
+- `path_prefix`: prefix to be applied to all paths
+- `optional_middlewares`: Register one or more optional middlewares to be applied to all requests.
+
+Optional middlewares can be one or more of:
+ - `init`: called before the request is processed
+ - `pre_validation`: called after the request is parsed but before validation
+ - `pre_invoke`: called after validation but before the handler is invoked
+ - `post_invoke`: called after the handler is invoked but before the response is sent
+
+The order in which middlewares are invoked are:
+`init |> read |> pre_validation |> validate |> pre_invoke |> invoke |> post_invoke`
+"""
+function register(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...)
+ registerDefaultApi(router, impl; path_prefix=path_prefix, optional_middlewares...)
+ return router
+end
+
+end # module TimeoutTestServer
diff --git a/test/server/timeouttest/TimeoutTestServer/src/apis/api_DefaultApi.jl b/test/server/timeouttest/TimeoutTestServer/src/apis/api_DefaultApi.jl
new file mode 100644
index 0000000..7e9f859
--- /dev/null
+++ b/test/server/timeouttest/TimeoutTestServer/src/apis/api_DefaultApi.jl
@@ -0,0 +1,39 @@
+# This file was generated by the Julia OpenAPI Code Generator
+# Do not modify this file directly. Modify the OpenAPI specification instead.
+
+
+function delayresponse_get_read(handler)
+ function delayresponse_get_read_handler(req::HTTP.Request)
+ openapi_params = Dict{String,Any}()
+ query_params = HTTP.queryparams(URIs.URI(req.target))
+ openapi_params["delay_seconds"] = OpenAPI.Servers.to_param(Int64, query_params, "delay_seconds", required=true, )
+ req.context[:openapi_params] = openapi_params
+
+ return handler(req)
+ end
+end
+
+function delayresponse_get_validate(handler)
+ function delayresponse_get_validate_handler(req::HTTP.Request)
+ openapi_params = req.context[:openapi_params]
+
+ OpenAPI.validate_param("delay_seconds", "delayresponse_get", :minimum, openapi_params["delay_seconds"], 0, false)
+
+ return handler(req)
+ end
+end
+
+function delayresponse_get_invoke(impl; post_invoke=nothing)
+ function delayresponse_get_invoke_handler(req::HTTP.Request)
+ openapi_params = req.context[:openapi_params]
+ ret = impl.delayresponse_get(req::HTTP.Request, openapi_params["delay_seconds"];)
+ resp = OpenAPI.Servers.server_response(ret)
+ return (post_invoke === nothing) ? resp : post_invoke(req, resp)
+ end
+end
+
+
+function registerDefaultApi(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...)
+ HTTP.register!(router, "GET", path_prefix * "/delayresponse", OpenAPI.Servers.middleware(impl, delayresponse_get_read, delayresponse_get_validate, delayresponse_get_invoke; optional_middlewares...))
+ return router
+end
diff --git a/test/server/timeouttest/TimeoutTestServer/src/modelincludes.jl b/test/server/timeouttest/TimeoutTestServer/src/modelincludes.jl
new file mode 100644
index 0000000..af7c2e0
--- /dev/null
+++ b/test/server/timeouttest/TimeoutTestServer/src/modelincludes.jl
@@ -0,0 +1,4 @@
+# This file was generated by the Julia OpenAPI Code Generator
+# Do not modify this file directly. Modify the OpenAPI specification instead.
+
+include("models/model_DelayresponseGet200Response.jl")
diff --git a/test/server/timeouttest/TimeoutTestServer/src/models/model_DelayresponseGet200Response.jl b/test/server/timeouttest/TimeoutTestServer/src/models/model_DelayresponseGet200Response.jl
new file mode 100644
index 0000000..c700d17
--- /dev/null
+++ b/test/server/timeouttest/TimeoutTestServer/src/models/model_DelayresponseGet200Response.jl
@@ -0,0 +1,30 @@
+# This file was generated by the Julia OpenAPI Code Generator
+# Do not modify this file directly. Modify the OpenAPI specification instead.
+
+
+@doc raw"""_delayresponse_get_200_response
+
+ DelayresponseGet200Response(;
+ delay_seconds=nothing,
+ )
+
+ - delay_seconds::String
+"""
+Base.@kwdef mutable struct DelayresponseGet200Response <: OpenAPI.APIModel
+ delay_seconds::Union{Nothing, String} = nothing
+
+ function DelayresponseGet200Response(delay_seconds, )
+ OpenAPI.validate_property(DelayresponseGet200Response, Symbol("delay_seconds"), delay_seconds)
+ return new(delay_seconds, )
+ end
+end # type DelayresponseGet200Response
+
+const _property_types_DelayresponseGet200Response = Dict{Symbol,String}(Symbol("delay_seconds")=>"String", )
+OpenAPI.property_type(::Type{ DelayresponseGet200Response }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_DelayresponseGet200Response[name]))}
+
+function check_required(o::DelayresponseGet200Response)
+ true
+end
+
+function OpenAPI.validate_property(::Type{ DelayresponseGet200Response }, name::Symbol, val)
+end
diff --git a/test/server/timeouttest/generate.sh b/test/server/timeouttest/generate.sh
new file mode 100755
index 0000000..dac6975
--- /dev/null
+++ b/test/server/timeouttest/generate.sh
@@ -0,0 +1,5 @@
+java -jar openapi-generator-cli.jar generate \
+ -i ../../specs/timeouttest.yaml \
+ -g julia-server \
+ -o TimeoutTestServer \
+ --additional-properties=packageName=TimeoutTestServer
diff --git a/test/server/timeouttest/timeouttest_server.jl b/test/server/timeouttest/timeouttest_server.jl
new file mode 100644
index 0000000..da3021e
--- /dev/null
+++ b/test/server/timeouttest/timeouttest_server.jl
@@ -0,0 +1,45 @@
+module TimeoutTestServerImpl
+
+using HTTP
+
+include("TimeoutTestServer/src/TimeoutTestServer.jl")
+
+using .TimeoutTestServer
+
+const server = Ref{Any}(nothing)
+
+"""
+delayresponse_get
+
+*invocation:* GET /delayresponse
+"""
+function delayresponse_get(req::HTTP.Request, delay_seconds::Int64;) :: TimeoutTestServer.DelayresponseGet200Response
+ sleep(delay_seconds)
+ return TimeoutTestServer.DelayresponseGet200Response(string(delay_seconds))
+end
+
+function stop(::HTTP.Request)
+ HTTP.close(server[])
+ return HTTP.Response(200, "")
+end
+
+function ping(::HTTP.Request)
+ return HTTP.Response(200, "")
+end
+
+function run_server(port=8081)
+ try
+ router = HTTP.Router()
+ router = TimeoutTestServer.register(router, @__MODULE__)
+ HTTP.register!(router, "GET", "/stop", stop)
+ HTTP.register!(router, "GET", "/ping", ping)
+ server[] = HTTP.serve!(router, port)
+ wait(server[])
+ catch ex
+ @error("Server error", exception=(ex, catch_backtrace()))
+ end
+end
+
+end # module TimeoutTestServerImpl
+
+TimeoutTestServerImpl.run_server()
\ No newline at end of file
diff --git a/test/specs/timeouttest.yaml b/test/specs/timeouttest.yaml
new file mode 100644
index 0000000..046cd78
--- /dev/null
+++ b/test/specs/timeouttest.yaml
@@ -0,0 +1,30 @@
+openapi: 3.0.3
+info:
+ title: Timeout Test Service
+ version: 1.0.0
+paths:
+ /delayresponse:
+ get:
+ summary: Delay Response Endpoint
+ parameters:
+ - name: delay_seconds
+ in: query
+ description: Number of seconds to delay the response
+ required: true
+ schema:
+ type: integer
+ minimum: 0
+ responses:
+ '200':
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ delay_seconds:
+ type: string
+ x-code-samples:
+ - lang: curl
+ source: |
+ curl -X GET "http://example.com/delayresponse?delay_seconds=5"
\ No newline at end of file