Skip to content

[julia] Add support for style, explode in query params #19238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/samples-julia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
# Using develop mode to install package so that it is easier to modify the package test files
julia -e "using Pkg; Pkg.develop(\"OpenAPI\");"
cd ~/.julia/dev/OpenAPI
git checkout v0.1.14
git checkout v0.1.25
cd $currdir
rm -rf ~/.julia/dev/OpenAPI/test/client/openapigenerator_petstore_v3/petstore
rm -rf ~/.julia/dev/OpenAPI/test/server/openapigenerator_petstore_v3/petstore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function _oacinternal_{{operationId}}(_api::{{classname}}{{#allParams}}{{#requir
OpenAPI.Clients.set_param(_ctx.path, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{paramName}}{{#isListContainer}}; collection_format="{{collectionFormat}}"{{/isListContainer}}) # type {{dataType}}
{{/pathParams}}
{{#queryParams}}
OpenAPI.Clients.set_param(_ctx.query, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{paramName}}{{#isListContainer}}; collection_format="{{collectionFormat}}"{{/isListContainer}}) # type {{dataType}}
OpenAPI.Clients.set_param(_ctx.query, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{paramName}}; style="{{style}}", is_explode={{isExplode}}{{#isListContainer}},collection_format="{{collectionFormat}}"{{/isListContainer}}) # type {{dataType}}
{{/queryParams}}
{{#headerParams}}
OpenAPI.Clients.set_param(_ctx.header, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{paramName}}{{#isListContainer}}; collection_format="{{collectionFormat}}"{{/isListContainer}}) # type {{dataType}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function {{operationId}}_read(handler)
path_params = HTTP.getparams(req){{#pathParams}}
openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"] = OpenAPI.Servers.to_param({{dataType}}, path_params, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{#required}}required=true, {{/required}}{{#isListContainer}}collection_format="{{collectionFormat}}", {{/isListContainer}}){{/pathParams}}{{/hasPathParams}}{{#hasQueryParams}}
query_params = HTTP.queryparams(URIs.URI(req.target)){{#queryParams}}
openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"] = OpenAPI.Servers.to_param({{dataType}}, query_params, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{#required}}required=true, {{/required}}{{#isListContainer}}collection_format="{{collectionFormat}}", {{/isListContainer}}){{/queryParams}}{{/hasQueryParams}}{{#hasHeaderParams}}
openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"] = OpenAPI.Servers.to_param({{dataType}}, query_params, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{#required}}required=true, {{/required}}style="{{style}}", is_explode={{isExplode}}{{#isListContainer}},collection_format="{{collectionFormat}}"{{/isListContainer}}){{/queryParams}}{{/hasQueryParams}}{{#hasHeaderParams}}
headers = Dict{String,String}(HTTP.headers(req)){{#headerParams}}
openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"] = OpenAPI.Servers.to_param({{dataType}}, headers, "{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}", {{#required}}required=true, {{/required}}{{#isListContainer}}collection_format="{{collectionFormat}}", {{/isListContainer}}){{/headerParams}}{{/hasHeaderParams}}{{#hasBodyParam}}{{#bodyParams}}
openapi_params["{{#lambda.escapeDollar}}{{baseName}}{{/lambda.escapeDollar}}"] = OpenAPI.Servers.to_param_type({{dataType}}, String(req.body)){{/bodyParams}}{{/hasBodyParam}}{{#hasFormParams}}
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/julia/src/apis/api_PetApi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const _returntypes_find_pets_by_status_PetApi = Dict{Regex,Type}(

function _oacinternal_find_pets_by_status(_api::PetApi, status::Vector{String}; _mediaType=nothing)
_ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_find_pets_by_status_PetApi, "/pet/findByStatus", ["petstore_auth", ])
OpenAPI.Clients.set_param(_ctx.query, "status", status) # type Vector{String}
OpenAPI.Clients.set_param(_ctx.query, "status", status; style="form", is_explode=false) # type Vector{String}
OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ])
OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType])
return _ctx
Expand Down Expand Up @@ -114,7 +114,7 @@ const _returntypes_find_pets_by_tags_PetApi = Dict{Regex,Type}(

function _oacinternal_find_pets_by_tags(_api::PetApi, tags::Vector{String}; _mediaType=nothing)
_ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_find_pets_by_tags_PetApi, "/pet/findByTags", ["petstore_auth", ])
OpenAPI.Clients.set_param(_ctx.query, "tags", tags) # type Vector{String}
OpenAPI.Clients.set_param(_ctx.query, "tags", tags; style="form", is_explode=false) # type Vector{String}
OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ])
OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType])
return _ctx
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/julia/src/apis/api_UserApi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ const _returntypes_login_user_UserApi = Dict{Regex,Type}(
function _oacinternal_login_user(_api::UserApi, username::String, password::String; _mediaType=nothing)

_ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_login_user_UserApi, "/user/login", [])
OpenAPI.Clients.set_param(_ctx.query, "username", username) # type String
OpenAPI.Clients.set_param(_ctx.query, "password", password) # type String
OpenAPI.Clients.set_param(_ctx.query, "username", username; style="form", is_explode=true) # type String
OpenAPI.Clients.set_param(_ctx.query, "password", password; style="form", is_explode=true) # type String
OpenAPI.Clients.set_header_accept(_ctx, ["application/xml", "application/json", ])
OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType])
return _ctx
Expand Down
4 changes: 2 additions & 2 deletions samples/server/petstore/julia/src/apis/api_PetApi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function find_pets_by_status_read(handler)
function find_pets_by_status_read_handler(req::HTTP.Request)
openapi_params = Dict{String,Any}()
query_params = HTTP.queryparams(URIs.URI(req.target))
openapi_params["status"] = OpenAPI.Servers.to_param(Vector{String}, query_params, "status", required=true, )
openapi_params["status"] = OpenAPI.Servers.to_param(Vector{String}, query_params, "status", required=true, style="form", is_explode=false)
req.context[:openapi_params] = openapi_params

return handler(req)
Expand Down Expand Up @@ -91,7 +91,7 @@ function find_pets_by_tags_read(handler)
function find_pets_by_tags_read_handler(req::HTTP.Request)
openapi_params = Dict{String,Any}()
query_params = HTTP.queryparams(URIs.URI(req.target))
openapi_params["tags"] = OpenAPI.Servers.to_param(Vector{String}, query_params, "tags", required=true, )
openapi_params["tags"] = OpenAPI.Servers.to_param(Vector{String}, query_params, "tags", required=true, style="form", is_explode=false)
req.context[:openapi_params] = openapi_params

return handler(req)
Expand Down
4 changes: 2 additions & 2 deletions samples/server/petstore/julia/src/apis/api_UserApi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ function login_user_read(handler)
function login_user_read_handler(req::HTTP.Request)
openapi_params = Dict{String,Any}()
query_params = HTTP.queryparams(URIs.URI(req.target))
openapi_params["username"] = OpenAPI.Servers.to_param(String, query_params, "username", required=true, )
openapi_params["password"] = OpenAPI.Servers.to_param(String, query_params, "password", required=true, )
openapi_params["username"] = OpenAPI.Servers.to_param(String, query_params, "username", required=true, style="form", is_explode=true)
openapi_params["password"] = OpenAPI.Servers.to_param(String, query_params, "password", required=true, style="form", is_explode=true)
req.context[:openapi_params] = openapi_params

return handler(req)
Expand Down
Loading