Skip to content

Commit 677936c

Browse files
authored
Merge pull request #20 from JuliaComputing/tan/misc
avoid error with HTTP/2 servers, update readme
2 parents 8872302 + 8c08879 commit 677936c

31 files changed

+117
-92
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ keywords = ["Swagger", "OpenAPI", "REST"]
44
license = "MIT"
55
desc = "OpenAPI server and client helper for Julia"
66
authors = ["Tanmay Mohapatra <[email protected]>", "JuliaHub"]
7-
version = "0.1.5"
7+
version = "0.1.6"
88

99
[deps]
1010
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Check out [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) for addit
3131

3232
Use [instructions](https://openapi-generator.tech/docs/generators) provided for the Julia OpenAPI code generator plugin to generate Julia code.
3333

34-
> Note: It requires the Julia code generator hosted in [this forked branch](https://github.com/JuliaComputing/openapi-generator/tree/juliahub/juliacodegen) of the OpenAPI code generator. The plan is to submit it for inclusion in the upstream repo soon.
34+
> Note: It requires the master branch of [openapi-generator](https://github.com/OpenAPITools/openapi-generator) until it is included in the next release. It is also hosted in [this forked branch](https://github.com/JuliaComputing/openapi-generator/tree/juliahub/juliacodegen) until then.
3535
3636
## Generated Code Structure
3737

src/client.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,15 @@ struct Client
101101
get_return_type::Function=get_api_return_type,
102102
long_polling_timeout::Int=DEFAULT_LONGPOLL_TIMEOUT_SECS,
103103
timeout::Int=DEFAULT_TIMEOUT_SECS,
104-
pre_request_hook::Function=noop_pre_request_hook)
105-
clntoptions = Dict{Symbol,Any}(:throw=>false, :verbose=>false)
104+
pre_request_hook::Function=noop_pre_request_hook,
105+
verbose::Bool=false,
106+
)
107+
clntoptions = Dict{Symbol,Any}(:throw=>false, :verbose=>verbose)
106108
downloader = Downloads.Downloader()
107109
downloader.easy_hook = (easy, opts) -> begin
108110
Downloads.Curl.setopt(easy, LibCURL.CURLOPT_LOW_SPEED_TIME, long_polling_timeout)
111+
# disable ALPN to support servers that enable both HTTP/2 and HTTP/1.1 on same port
112+
Downloads.Curl.setopt(easy, LibCURL.CURLOPT_SSL_ENABLE_ALPN, 0)
109113
end
110114
new(root, headers, get_return_type, clntoptions, downloader, Ref{Int}(timeout), pre_request_hook, long_polling_timeout)
111115
end

test/client/allany/AllAnyClient/src/apis/api_DefaultApi.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ This can be used to construct the `OpenAPI.Clients.Client` instance.
1111
"""
1212
basepath(::Type{ DefaultApi }) = "http://localhost"
1313

14-
const _returntypes_echo_anyof_mapped_pets_post = Dict{Regex,Type}(
14+
const _returntypes_echo_anyof_mapped_pets_post_DefaultApi = Dict{Regex,Type}(
1515
Regex("^" * replace("200", "x"=>".") * "\$") => AnyOfMappedPets,
1616
)
1717

1818
function _oacinternal_echo_anyof_mapped_pets_post(_api::DefaultApi, any_of_mapped_pets::AnyOfMappedPets; _mediaType=nothing)
19-
_ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_echo_anyof_mapped_pets_post, "/echo_anyof_mapped_pets", [], any_of_mapped_pets)
19+
_ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_echo_anyof_mapped_pets_post_DefaultApi, "/echo_anyof_mapped_pets", [], any_of_mapped_pets)
2020
OpenAPI.Clients.set_header_accept(_ctx, ["application/json", ])
2121
OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", ] : [_mediaType])
2222
return _ctx
@@ -37,12 +37,12 @@ function echo_anyof_mapped_pets_post(_api::DefaultApi, response_stream::Channel,
3737
return OpenAPI.Clients.exec(_ctx, response_stream)
3838
end
3939

40-
const _returntypes_echo_anyof_pets_post = Dict{Regex,Type}(
40+
const _returntypes_echo_anyof_pets_post_DefaultApi = Dict{Regex,Type}(
4141
Regex("^" * replace("200", "x"=>".") * "\$") => AnyOfPets,
4242
)
4343

4444
function _oacinternal_echo_anyof_pets_post(_api::DefaultApi, any_of_pets::AnyOfPets; _mediaType=nothing)
45-
_ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_echo_anyof_pets_post, "/echo_anyof_pets", [], any_of_pets)
45+
_ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_echo_anyof_pets_post_DefaultApi, "/echo_anyof_pets", [], any_of_pets)
4646
OpenAPI.Clients.set_header_accept(_ctx, ["application/json", ])
4747
OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", ] : [_mediaType])
4848
return _ctx
@@ -63,12 +63,12 @@ function echo_anyof_pets_post(_api::DefaultApi, response_stream::Channel, any_of
6363
return OpenAPI.Clients.exec(_ctx, response_stream)
6464
end
6565

66-
const _returntypes_echo_oneof_mapped_pets_post = Dict{Regex,Type}(
66+
const _returntypes_echo_oneof_mapped_pets_post_DefaultApi = Dict{Regex,Type}(
6767
Regex("^" * replace("200", "x"=>".") * "\$") => OneOfMappedPets,
6868
)
6969

7070
function _oacinternal_echo_oneof_mapped_pets_post(_api::DefaultApi, one_of_mapped_pets::OneOfMappedPets; _mediaType=nothing)
71-
_ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_echo_oneof_mapped_pets_post, "/echo_oneof_mapped_pets", [], one_of_mapped_pets)
71+
_ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_echo_oneof_mapped_pets_post_DefaultApi, "/echo_oneof_mapped_pets", [], one_of_mapped_pets)
7272
OpenAPI.Clients.set_header_accept(_ctx, ["application/json", ])
7373
OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", ] : [_mediaType])
7474
return _ctx
@@ -89,12 +89,12 @@ function echo_oneof_mapped_pets_post(_api::DefaultApi, response_stream::Channel,
8989
return OpenAPI.Clients.exec(_ctx, response_stream)
9090
end
9191

92-
const _returntypes_echo_oneof_pets_post = Dict{Regex,Type}(
92+
const _returntypes_echo_oneof_pets_post_DefaultApi = Dict{Regex,Type}(
9393
Regex("^" * replace("200", "x"=>".") * "\$") => OneOfPets,
9494
)
9595

9696
function _oacinternal_echo_oneof_pets_post(_api::DefaultApi, one_of_pets::OneOfPets; _mediaType=nothing)
97-
_ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_echo_oneof_pets_post, "/echo_oneof_pets", [], one_of_pets)
97+
_ctx = OpenAPI.Clients.Ctx(_api.client, "POST", _returntypes_echo_oneof_pets_post_DefaultApi, "/echo_oneof_pets", [], one_of_pets)
9898
OpenAPI.Clients.set_header_accept(_ctx, ["application/json", ])
9999
OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? ["application/json", ] : [_mediaType])
100100
return _ctx

test/client/allany/AllAnyClient/src/models/model_AnyOfMappedPets.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ function OpenAPI.property_type(::Type{ AnyOfMappedPets }, name::Symbol, json::Di
2222
end
2323
throw(OpenAPI.ValidationException("Invalid discriminator value: $discriminator for AnyOfMappedPets"))
2424
end
25+

test/client/allany/AllAnyClient/src/models/model_AnyOfPets.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ function OpenAPI.property_type(::Type{ AnyOfPets }, name::Symbol, json::Dict{Str
2222
end
2323
throw(OpenAPI.ValidationException("Invalid discriminator value: $discriminator for AnyOfPets"))
2424
end
25+

test/client/allany/AllAnyClient/src/models/model_Cat.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ end
3737

3838
function OpenAPI.validate_property(::Type{ Cat }, name::Symbol, val)
3939
end
40+

test/client/allany/AllAnyClient/src/models/model_CatAllOf.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ end
3232

3333
function OpenAPI.validate_property(::Type{ CatAllOf }, name::Symbol, val)
3434
end
35+

test/client/allany/AllAnyClient/src/models/model_Dog.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ function OpenAPI.validate_property(::Type{ Dog }, name::Symbol, val)
4040
OpenAPI.validate_param(name, "Dog", :enum, val, ["Dingo", "Husky", "Retriever", "Shepherd"])
4141
end
4242
end
43+

test/client/allany/AllAnyClient/src/models/model_DogAllOf.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ function OpenAPI.validate_property(::Type{ DogAllOf }, name::Symbol, val)
3535
OpenAPI.validate_param(name, "DogAllOf", :enum, val, ["Dingo", "Husky", "Retriever", "Shepherd"])
3636
end
3737
end
38+

0 commit comments

Comments
 (0)