aj-foster/open-api-generator

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

xadhoom opened this issue · 1 comments

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

Can be resolved with #13