From ec93c996ae8a48c3be3782353295dc6bd9cbfdae Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Tue, 5 Jul 2022 23:08:26 +0700 Subject: [PATCH] Fix generate crash when have some unknown field Found by accidentally add `$schema` to the json for autocompletion reason. The `Tesla.OpenApi.Spec.models/1` at line 278 will crash because of for iterate `defs` over map which's cause `schema` to be the value of field `$schema`. Fixes by filter only schema that is map. --- lib/tesla/openapi/spec.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tesla/openapi/spec.ex b/lib/tesla/openapi/spec.ex index 0bdb774..0a74241 100644 --- a/lib/tesla/openapi/spec.ex +++ b/lib/tesla/openapi/spec.ex @@ -275,7 +275,7 @@ defmodule Tesla.OpenApi.Spec do defp models(%{"components" => _}), do: [] defp models(defs) when is_map(defs) do - for {name, schema} <- defs do + for {name, schema} when is_map(schema) <- defs do %Model{ name: name, title: schema["title"],