GenieFramework / SwaggerMarkdown.jl

MIT License
10 stars 2 forks source link

Example code errors #5

Open sitch opened 2 years ago

sitch commented 2 years ago

On julia 1.7.1 errors out when running the example:

using JSON
using SwaggerMarkdown

@swagger """
/doge:
  get:
    description: doge
    responses:
      '200':
        description: Returns a doge.
"""

# the version of the OpenAPI used is required
openApi_version = "2.0"

# the info of the API, title and version of the info are required
info = Dict{String,Any}()
info["title"] = "Doge to the moon"
info["version"] = "1.0.5"

openApi = OpenAPI(openApi_version, info)

swagger_document = build(openApi)
swagger_json = JSON.json(swagger_document)
$ julia --project=. src/SwaggerSpec.jl
ERROR: LoadError: AssertionError: typeof(forward!(composer.input)) == DocumentStartEvent
Stacktrace:
  [1] compose_document(composer::YAML.Composer)
    @ YAML ~/.julia/packages/YAML/IXUQ4/src/composer.jl:49
  [2] compose(events::YAML.EventStream)
    @ YAML ~/.julia/packages/YAML/IXUQ4/src/composer.jl:38
  [3] load(ts::YAML.TokenStream, constructor::YAML.Constructor)
    @ YAML ~/.julia/packages/YAML/IXUQ4/src/YAML.jl:38
  [4] load(ts::YAML.TokenStream, more_constructors::Nothing, multi_constructors::Dict{Any, Any}; dicttype::Type{Dict{String, Any}}, constructorType::typeof(YAML.SafeConstructor))
    @ YAML ~/.julia/packages/YAML/IXUQ4/src/YAML.jl:44
  [5] #load#10
    @ ~/.julia/packages/YAML/IXUQ4/src/YAML.jl:47 [inlined]
  [6] #16
    @ ~/.julia/packages/YAML/IXUQ4/src/YAML.jl:96 [inlined]
  [7] open(::YAML.var"#16#17"{Base.Pairs{Symbol, DataType, Tuple{Symbol}, NamedTuple{(:dicttype,), Tuple{DataType}}}, Tuple{}}, ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./io.jl:330
  [8] open
    @ ./io.jl:328 [inlined]
  [9] #load_file#15
    @ ~/.julia/packages/YAML/IXUQ4/src/YAML.jl:94 [inlined]
 [10] parse_spec()
    @ SwaggerMarkdown ~/.julia/packages/SwaggerMarkdown/PQQtk/src/Utils.jl:9
 [11] build(spec::OpenAPI; doc_parser::typeof(SwaggerMarkdown.parse_spec))
    @ SwaggerMarkdown ~/.julia/packages/SwaggerMarkdown/PQQtk/src/SwaggerMarkdown.jl:36
 [12] build(spec::OpenAPI)
    @ SwaggerMarkdown ~/.julia/packages/SwaggerMarkdown/PQQtk/src/SwaggerMarkdown.jl:34
 [13] top-level scope
    @ ~/sites/fortress/pair-api/src/SwaggerSpec.jl:23
sitch commented 2 years ago

Seems to be an issue with YAML https://github.com/JuliaData/YAML.jl/issues/117

jiachengzhang1 commented 2 years ago

I tried the example using 1.7.1 but I'm not able to reproduce the error. Can you share how your project is structured?

sitch commented 2 years ago

I tried this with a default genie app, and put the file in a few spots..