|
1 | 1 | module SwagUI |
2 | 2 |
|
3 | 3 | using JSON |
4 | | -using Genie, Genie.Router |
5 | 4 |
|
6 | 5 | include("Options.jl") |
7 | 6 | include("Builders.jl") |
8 | 7 |
|
9 | 8 | export Options, render_swagger |
10 | 9 |
|
11 | 10 | """ |
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...) |
13 | 13 |
|
14 | 14 | Render Swagger UI's HTML as `String`, based on the options passed in. If a vaid `swagger_doc` is passed, |
15 | 15 | the `url` and `urls` in the `Options.swagger_options` are ignored by the UI. If `swagger_doc` is `nothing`, |
16 | 16 | `url` or `urls` has to be included in the `Options.swagger_options`. |
17 | 17 |
|
| 18 | +Options can be passed as an `Options` struct or indirectly via keyword arguments (see `Options`). |
| 19 | +
|
18 | 20 | # Arguments |
19 | 21 | Required: |
20 | 22 | - `swagger_doc::Union{Dict{String, Any}, Nothing}` : The swagger specification file `swagger.json` as a `Dict{String, Any}`. |
21 | 23 | """ |
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 | + |
23 | 28 | js_string = build_js_string(options, swagger_doc) |
24 | 29 | html_string = build_html_string(options, js_string) |
25 | 30 |
|
|
0 commit comments