Skip to content

Commit 24b8e5a

Browse files
authored
Merge pull request #8 from ExpandingMan/em/dropdep1
moved Genie to test dependency
2 parents f8f2362 + 467f536 commit 24b8e5a

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

Project.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
name = "SwagUI"
22
uuid = "bf05d729-34b2-4f1f-a2f1-2452bece7ebc"
33
authors = ["Jiacheng Zhang <[email protected]>"]
4-
version = "0.9.0"
4+
version = "0.9.1"
55

66
[deps]
7-
Genie = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
87
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
98
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
109
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1110

1211
[compat]
1312
julia = "1.5, 1.6"
1413
JSON = "0.21.1"
15-
Genie = "1"
16-
HTTP = "0.8, 0.9"
14+
HTTP = "0.8, 0.9"
15+
16+
[extras]
17+
Genie = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
18+
19+
[targets]
20+
test = ["Genie"]

src/SwagUI.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
module SwagUI
22

33
using JSON
4-
using Genie, Genie.Router
54

65
include("Options.jl")
76
include("Builders.jl")
87

98
export Options, render_swagger
109

1110
"""
12-
render_swagger(swagger_doc::Union{Dict{String, Any}, Nothing})::String
11+
render_swagger(swagger_doc::Union{Dict{String, Any}, Nothing};
12+
options=nothing, kw...)
1313
1414
Render Swagger UI's HTML as `String`, based on the options passed in. If a vaid `swagger_doc` is passed,
1515
the `url` and `urls` in the `Options.swagger_options` are ignored by the UI. If `swagger_doc` is `nothing`,
1616
`url` or `urls` has to be included in the `Options.swagger_options`.
1717
18+
Options can be passed as an `Options` struct or indirectly via keyword arguments (see `Options`).
19+
1820
# Arguments
1921
Required:
2022
- `swagger_doc::Union{Dict{String, Any}, Nothing}` : The swagger specification file `swagger.json` as a `Dict{String, Any}`.
2123
"""
22-
function render_swagger(swagger_doc::Union{Dict{String, Any}, Nothing}; options::Options=Options())::String
24+
function render_swagger(swagger_doc::Union{AbstractDict{<:AbstractString,<:Any}, Nothing};
25+
options::Union{Options,Nothing}=nothing, kw...)::String
26+
isnothing(options) && (options = Options(;kw...))
27+
2328
js_string = build_js_string(options, swagger_doc)
2429
html_string = build_html_string(options, js_string)
2530

test/app.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ function serve_assets(path::String; excludes::Array{String, 1}=Array{String, 1}(
1414
for file in files
1515
if !(file in excludes)
1616
route(file) do
17-
serve_static_file(file, root=root)
17+
open(read, joinpath(root, file)) |> String
1818
end
1919
end
2020
end
2121
end
2222
end
2323

2424
serve_assets(ASSETS_PATH)
25-
Genie.AppServer.startup(PORT, HOST; open_browser = false, verbose = true)
25+
Genie.AppServer.startup(PORT, HOST; open_browser = false, verbose = true, async = true)
2626

2727
# basic settings
2828
swagger_document = JSON.parsefile(joinpath(ASSETS_PATH, "swagger.json"))
@@ -94,4 +94,4 @@ end
9494
@test occursin("<link rel='stylesheet' type='text/css' href=$(stylesheet_path) />", html_string)
9595
@test occursin("<title>$(title)</title>", html_string)
9696
@test occursin("<link rel='icon' href=$(favicon_path) />", html_string)
97-
end
97+
end

0 commit comments

Comments
 (0)