diff --git a/lib/rolodex/processors/open_api.ex b/lib/rolodex/processors/open_api.ex index d89e31e..168bb24 100644 --- a/lib/rolodex/processors/open_api.ex +++ b/lib/rolodex/processors/open_api.ex @@ -186,13 +186,18 @@ defmodule Rolodex.Processors.OpenAPI do |> process_content_body_headers(rest) end - defp process_content_body_ref_data(%{schema: schema, examples: examples}) do + defp process_content_body_ref_data(%{schema: schema, examples: examples}) + when map_size(examples) > 0 do %{ schema: process_schema_field(schema), examples: process_content_body_examples(examples) } end + defp process_content_body_ref_data(%{schema: schema}) do + %{schema: process_schema_field(schema)} + end + defp process_content_body_examples(examples), do: Map.new(examples, fn {name, example} -> {name, %{value: example}} end) diff --git a/mix.exs b/mix.exs index bf7dba6..7fe31c8 100644 --- a/mix.exs +++ b/mix.exs @@ -6,7 +6,7 @@ defmodule Rolodex.MixProject do app: :rolodex, name: "Rolodex", description: "Automated docs generation", - version: "0.10.0", + version: "0.10.1", elixir: "~> 1.7", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, diff --git a/test/rolodex_test.exs b/test/rolodex_test.exs index 685f280..be94832 100644 --- a/test/rolodex_test.exs +++ b/test/rolodex_test.exs @@ -106,7 +106,6 @@ defmodule RolodexTest do "ErrorResponse" => %{ "content" => %{ "application/json" => %{ - "examples" => %{}, "schema" => %{ "properties" => %{ "message" => %{"type" => "string"}, @@ -136,13 +135,11 @@ defmodule RolodexTest do }, "content" => %{ "application/json" => %{ - "examples" => %{}, "schema" => %{ "$ref" => "#/components/schemas/User" } }, "application/lolsob" => %{ - "examples" => %{}, "schema" => %{ "type" => "array", "items" => %{ @@ -639,7 +636,6 @@ defmodule RolodexTest do "ErrorResponse" => %{ "content" => %{ "application/json" => %{ - "examples" => %{}, "schema" => %{ "properties" => %{ "message" => %{"type" => "string"},