Skip to content

Commit

Permalink
Regen Julia server stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
sverhoeven committed Sep 24, 2024
1 parent 7081923 commit 83bfd34
Show file tree
Hide file tree
Showing 17 changed files with 335 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ __pycache__
/venv
python/.venv/
python/heat.toml
RemoteBMI.jl/example/Project.toml
RemoteBMI.jl/example/Project.toml
openapi-generator-cli.jar
openapitools.json
3 changes: 2 additions & 1 deletion RemoteBMI.jl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ BestieTemplate.generate("RemoteBMI.jl")
The openapi server stubs where generated using the following command:

```shell
npx @openapitools/openapi-generator-cli generate -i ./openapi.yaml -g julia-server -o julia-server --additional-properties=packageName=BmiServer --additional-properties=exportModels=true
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.8.0/openapi-generator-cli-7.8.0.jar -O openapi-generator-cli.jar
java -jar ./openapi-generator-cli.jar generate -i ./openapi.yaml -g julia-server -o julia-server --additional-properties=packageName=BmiServer --additional-properties=exportModels=true
# Copy the generated files to RemoteBMI.jl/src/
```
24 changes: 14 additions & 10 deletions RemoteBMI.jl/src/BmiServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The following server methods must be implemented:
- **get_component_name**
- *invocation:* GET /get_component_name
- *signature:* get_component_name(req::HTTP.Request;) -> String
- *signature:* get_component_name(req::HTTP.Request;) -> GetComponentNameResponse
- **get_input_item_count**
- *invocation:* GET /get_input_item_count
- *signature:* get_input_item_count(req::HTTP.Request;) -> Int64
Expand All @@ -36,13 +36,13 @@ The following server methods must be implemented:
- *signature:* get_grid_size(req::HTTP.Request, grid::Int64;) -> Int64
- **get_grid_type**
- *invocation:* GET /get_grid_type/{grid}
- *signature:* get_grid_type(req::HTTP.Request, grid::Int64;) -> BmiGetGridTypeResponse
- *signature:* get_grid_type(req::HTTP.Request, grid::Int64;) -> GetGridTypeResponse
- **finalize**
- *invocation:* DELETE /finalize
- *signature:* finalize(req::HTTP.Request;) -> Nothing
- **initialize**
- *invocation:* POST /initialize
- *signature:* initialize(req::HTTP.Request, bmi_initialize_request::BmiInitializeRequest;) -> Nothing
- *signature:* initialize(req::HTTP.Request, initialize_request::InitializeRequest;) -> Nothing
- **update**
- *invocation:* POST /update
- *signature:* update(req::HTTP.Request;) -> Nothing
Expand All @@ -63,7 +63,7 @@ The following server methods must be implemented:
- *signature:* set_value(req::HTTP.Request, name::String, request_body::Vector{Float64};) -> Nothing
- **set_value_at_indices**
- *invocation:* POST /set_value_at_indices/{name}
- *signature:* set_value_at_indices(req::HTTP.Request, name::String, bmi_set_value_at_indices_request::BmiSetValueAtIndicesRequest;) -> Nothing
- *signature:* set_value_at_indices(req::HTTP.Request, name::String, set_value_at_indices_request::SetValueAtIndicesRequest;) -> Nothing
- **get_current_time**
- *invocation:* GET /get_current_time
- *signature:* get_current_time(req::HTTP.Request;) -> Float64
Expand All @@ -78,7 +78,7 @@ The following server methods must be implemented:
- *signature:* get_time_step(req::HTTP.Request;) -> Float64
- **get_time_units**
- *invocation:* GET /get_time_units
- *signature:* get_time_units(req::HTTP.Request;) -> String
- *signature:* get_time_units(req::HTTP.Request;) -> GetTimeUnitsResponse
- **get_grid_origin**
- *invocation:* GET /get_grid_origin/{grid}
- *signature:* get_grid_origin(req::HTTP.Request, grid::Int64;) -> Vector{Float64}
Expand Down Expand Up @@ -123,10 +123,10 @@ The following server methods must be implemented:
- *signature:* get_var_nbytes(req::HTTP.Request, name::String;) -> Int64
- **get_var_type**
- *invocation:* GET /get_var_type/{name}
- *signature:* get_var_type(req::HTTP.Request, name::String;) -> String
- *signature:* get_var_type(req::HTTP.Request, name::String;) -> GetVarTypeResponse
- **get_var_units**
- *invocation:* GET /get_var_units/{name}
- *signature:* get_var_units(req::HTTP.Request, name::String;) -> String
- *signature:* get_var_units(req::HTTP.Request, name::String;) -> GetVarUnitsResponse
"""
module BmiServer

Expand Down Expand Up @@ -187,10 +187,14 @@ function register(router::HTTP.Router, impl; path_prefix::String="", optional_mi
end

# export models
export BmiGetGridTypeResponse
export BmiInitializeRequest
export BmiSetValueAtIndicesRequest
export GetComponentNameResponse
export GetGridTypeResponse
export GetTimeUnitsResponse
export GetVarLocationResponseLocation
export GetVarTypeResponse
export GetVarUnitsResponse
export InitializeRequest
export ProblemDetails
export SetValueAtIndicesRequest

end # module BmiServer
4 changes: 4 additions & 0 deletions RemoteBMI.jl/src/apis/api_GettersApi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function get_value_validate(handler)
function get_value_validate_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]

OpenAPI.validate_param("name", "get_value", :minLength, openapi_params["name"], 1)

return handler(req)
end
end
Expand Down Expand Up @@ -46,6 +48,8 @@ function get_value_at_indices_validate(handler)
function get_value_at_indices_validate_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]

OpenAPI.validate_param("name", "get_value_at_indices", :minLength, openapi_params["name"], 1)

return handler(req)
end
end
Expand Down
4 changes: 2 additions & 2 deletions RemoteBMI.jl/src/apis/api_IRFApi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
function initialize_read(handler)
function initialize_read_handler(req::HTTP.Request)
openapi_params = Dict{String,Any}()
openapi_params["BmiInitializeRequest"] = OpenAPI.Servers.to_param_type(BmiInitializeRequest, String(req.body))
openapi_params["InitializeRequest"] = OpenAPI.Servers.to_param_type(InitializeRequest, String(req.body))
req.context[:openapi_params] = openapi_params

return handler(req)
Expand All @@ -49,7 +49,7 @@ end
function initialize_invoke(impl; post_invoke=nothing)
function initialize_invoke_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]
ret = impl.initialize(req::HTTP.Request, openapi_params["BmiInitializeRequest"];)
ret = impl.initialize(req::HTTP.Request, openapi_params["InitializeRequest"];)
resp = OpenAPI.Servers.server_response(ret)
return (post_invoke === nothing) ? resp : post_invoke(req, resp)
end
Expand Down
8 changes: 6 additions & 2 deletions RemoteBMI.jl/src/apis/api_SettersApi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function set_value_validate(handler)
function set_value_validate_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]

OpenAPI.validate_param("name", "set_value", :minLength, openapi_params["name"], 1)

return handler(req)
end
end
Expand All @@ -36,7 +38,7 @@ function set_value_at_indices_read(handler)
openapi_params = Dict{String,Any}()
path_params = HTTP.getparams(req)
openapi_params["name"] = OpenAPI.Servers.to_param(String, path_params, "name", required=true, )
openapi_params["BmiSetValueAtIndicesRequest"] = OpenAPI.Servers.to_param_type(BmiSetValueAtIndicesRequest, String(req.body))
openapi_params["SetValueAtIndicesRequest"] = OpenAPI.Servers.to_param_type(SetValueAtIndicesRequest, String(req.body))
req.context[:openapi_params] = openapi_params

return handler(req)
Expand All @@ -47,14 +49,16 @@ function set_value_at_indices_validate(handler)
function set_value_at_indices_validate_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]

OpenAPI.validate_param("name", "set_value_at_indices", :minLength, openapi_params["name"], 1)

return handler(req)
end
end

function set_value_at_indices_invoke(impl; post_invoke=nothing)
function set_value_at_indices_invoke_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]
ret = impl.set_value_at_indices(req::HTTP.Request, openapi_params["name"], openapi_params["BmiSetValueAtIndicesRequest"];)
ret = impl.set_value_at_indices(req::HTTP.Request, openapi_params["name"], openapi_params["SetValueAtIndicesRequest"];)
resp = OpenAPI.Servers.server_response(ret)
return (post_invoke === nothing) ? resp : post_invoke(req, resp)
end
Expand Down
12 changes: 12 additions & 0 deletions RemoteBMI.jl/src/apis/api_VariableInformationApi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function get_var_grid_validate(handler)
function get_var_grid_validate_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]

OpenAPI.validate_param("name", "get_var_grid", :minLength, openapi_params["name"], 1)

return handler(req)
end
end
Expand Down Expand Up @@ -45,6 +47,8 @@ function get_var_itemsize_validate(handler)
function get_var_itemsize_validate_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]

OpenAPI.validate_param("name", "get_var_itemsize", :minLength, openapi_params["name"], 1)

return handler(req)
end
end
Expand Down Expand Up @@ -73,6 +77,8 @@ function get_var_location_validate(handler)
function get_var_location_validate_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]

OpenAPI.validate_param("name", "get_var_location", :minLength, openapi_params["name"], 1)

return handler(req)
end
end
Expand Down Expand Up @@ -101,6 +107,8 @@ function get_var_nbytes_validate(handler)
function get_var_nbytes_validate_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]

OpenAPI.validate_param("name", "get_var_nbytes", :minLength, openapi_params["name"], 1)

return handler(req)
end
end
Expand Down Expand Up @@ -129,6 +137,8 @@ function get_var_type_validate(handler)
function get_var_type_validate_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]

OpenAPI.validate_param("name", "get_var_type", :minLength, openapi_params["name"], 1)

return handler(req)
end
end
Expand Down Expand Up @@ -157,6 +167,8 @@ function get_var_units_validate(handler)
function get_var_units_validate_handler(req::HTTP.Request)
openapi_params = req.context[:openapi_params]

OpenAPI.validate_param("name", "get_var_units", :minLength, openapi_params["name"], 1)

return handler(req)
end
end
Expand Down
10 changes: 7 additions & 3 deletions RemoteBMI.jl/src/modelincludes.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# This file was generated by the Julia OpenAPI Code Generator
# Do not modify this file directly. Modify the OpenAPI specification instead.

include("models/model_BmiGetGridTypeResponse.jl")
include("models/model_BmiInitializeRequest.jl")
include("models/model_BmiSetValueAtIndicesRequest.jl")
include("models/model_GetComponentNameResponse.jl")
include("models/model_GetGridTypeResponse.jl")
include("models/model_GetTimeUnitsResponse.jl")
include("models/model_GetVarLocationResponseLocation.jl")
include("models/model_GetVarTypeResponse.jl")
include("models/model_GetVarUnitsResponse.jl")
include("models/model_InitializeRequest.jl")
include("models/model_ProblemDetails.jl")
include("models/model_SetValueAtIndicesRequest.jl")
34 changes: 34 additions & 0 deletions RemoteBMI.jl/src/models/model_GetComponentNameResponse.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file was generated by the Julia OpenAPI Code Generator
# Do not modify this file directly. Modify the OpenAPI specification instead.


@doc raw"""GetComponentNameResponse
GetComponentNameResponse(;
name=nothing,
)
- name::String
"""
Base.@kwdef mutable struct GetComponentNameResponse <: OpenAPI.APIModel
name::Union{Nothing, String} = nothing

function GetComponentNameResponse(name, )
OpenAPI.validate_property(GetComponentNameResponse, Symbol("name"), name)
return new(name, )
end
end # type GetComponentNameResponse

const _property_types_GetComponentNameResponse = Dict{Symbol,String}(Symbol("name")=>"String", )
OpenAPI.property_type(::Type{ GetComponentNameResponse }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_GetComponentNameResponse[name]))}

function check_required(o::GetComponentNameResponse)
o.name === nothing && (return false)
true
end

function OpenAPI.validate_property(::Type{ GetComponentNameResponse }, name::Symbol, val)
if name === Symbol("name")
OpenAPI.validate_param(name, "GetComponentNameResponse", :minLength, val, 1)
end
end
34 changes: 34 additions & 0 deletions RemoteBMI.jl/src/models/model_GetGridTypeResponse.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file was generated by the Julia OpenAPI Code Generator
# Do not modify this file directly. Modify the OpenAPI specification instead.


@doc raw"""GetGridTypeResponse
GetGridTypeResponse(;
type=nothing,
)
- type::String
"""
Base.@kwdef mutable struct GetGridTypeResponse <: OpenAPI.APIModel
type::Union{Nothing, String} = nothing

function GetGridTypeResponse(type, )
OpenAPI.validate_property(GetGridTypeResponse, Symbol("type"), type)
return new(type, )
end
end # type GetGridTypeResponse

const _property_types_GetGridTypeResponse = Dict{Symbol,String}(Symbol("type")=>"String", )
OpenAPI.property_type(::Type{ GetGridTypeResponse }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_GetGridTypeResponse[name]))}

function check_required(o::GetGridTypeResponse)
o.type === nothing && (return false)
true
end

function OpenAPI.validate_property(::Type{ GetGridTypeResponse }, name::Symbol, val)
if name === Symbol("type")
OpenAPI.validate_param(name, "GetGridTypeResponse", :enum, val, ["scalar", "points", "vector", "unstructured", "structured_quadrilateral", "rectilinear", "uniform_rectilinear"])
end
end
34 changes: 34 additions & 0 deletions RemoteBMI.jl/src/models/model_GetTimeUnitsResponse.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file was generated by the Julia OpenAPI Code Generator
# Do not modify this file directly. Modify the OpenAPI specification instead.


@doc raw"""GetTimeUnitsResponse
GetTimeUnitsResponse(;
units=nothing,
)
- units::String
"""
Base.@kwdef mutable struct GetTimeUnitsResponse <: OpenAPI.APIModel
units::Union{Nothing, String} = nothing

function GetTimeUnitsResponse(units, )
OpenAPI.validate_property(GetTimeUnitsResponse, Symbol("units"), units)
return new(units, )
end
end # type GetTimeUnitsResponse

const _property_types_GetTimeUnitsResponse = Dict{Symbol,String}(Symbol("units")=>"String", )
OpenAPI.property_type(::Type{ GetTimeUnitsResponse }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_GetTimeUnitsResponse[name]))}

function check_required(o::GetTimeUnitsResponse)
o.units === nothing && (return false)
true
end

function OpenAPI.validate_property(::Type{ GetTimeUnitsResponse }, name::Symbol, val)
if name === Symbol("units")
OpenAPI.validate_param(name, "GetTimeUnitsResponse", :minLength, val, 1)
end
end
33 changes: 29 additions & 4 deletions RemoteBMI.jl/src/models/model_GetVarLocationResponseLocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,33 @@
# Do not modify this file directly. Modify the OpenAPI specification instead.


if !isdefined(@__MODULE__, :GetVarLocationResponseLocation)
const GetVarLocationResponseLocation = String
else
@warn("Skipping redefinition of GetVarLocationResponseLocation to String")
@doc raw"""GetVarLocationResponseLocation
GetVarLocationResponseLocation(;
location="node",
)
- location::String
"""
Base.@kwdef mutable struct GetVarLocationResponseLocation <: OpenAPI.APIModel
location::Union{Nothing, String} = "node"

function GetVarLocationResponseLocation(location, )
OpenAPI.validate_property(GetVarLocationResponseLocation, Symbol("location"), location)
return new(location, )
end
end # type GetVarLocationResponseLocation

const _property_types_GetVarLocationResponseLocation = Dict{Symbol,String}(Symbol("location")=>"String", )
OpenAPI.property_type(::Type{ GetVarLocationResponseLocation }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_GetVarLocationResponseLocation[name]))}

function check_required(o::GetVarLocationResponseLocation)
o.location === nothing && (return false)
true
end

function OpenAPI.validate_property(::Type{ GetVarLocationResponseLocation }, name::Symbol, val)
if name === Symbol("location")
OpenAPI.validate_param(name, "GetVarLocationResponseLocation", :enum, val, ["node", "edge", "face"])
end
end
Loading

0 comments on commit 83bfd34

Please sign in to comment.