aj-foster / open-api-generator

Open API code generator for Elixir
MIT License
97 stars 13 forks source link

Generation fails with `KeyError` when server variable has no `enum` key #15

Closed xadhoom closed 1 year ago

xadhoom commented 1 year ago

Sample error while generating from GH openapi spec (as taken from official repo)

** (KeyError) key "enum" not found in: %{"default" => "HOSTNAME", "description" => "Self-hosted Enterprise Server hostname"}
    :erlang.map_get("enum", %{"default" => "HOSTNAME", "description" => "Self-hosted Enterprise Server hostname"})
    (oapi_generator 0.0.6) lib/open_api/spec/server/variable.ex:27: OpenAPI.Spec.Server.Variable.decode/2
    (oapi_generator 0.0.6) lib/open_api/spec/helper.ex:21: OpenAPI.Spec.Helper.with_path/4
    (oapi_generator 0.0.6) lib/open_api/spec/server.ex:44: anonymous fn/2 in OpenAPI.Spec.Server.decode_variables/2
    (stdlib 4.3.1) maps.erl:411: :maps.fold_1/3
    (oapi_generator 0.0.6) lib/open_api/spec/helper.ex:21: OpenAPI.Spec.Helper.with_path/4
    (oapi_generator 0.0.6) lib/open_api/spec/server.ex:29: OpenAPI.Spec.Server.decode/2
    (oapi_generator 0.0.6) lib/open_api/spec/helper.ex:21: OpenAPI.Spec.Helper.with_path/4
xadhoom commented 1 year ago

Can be resolved with #13