From 08373bbc6c7126f024523ad8385e556fecb77716 Mon Sep 17 00:00:00 2001 From: Magnus Henoch Date: Thu, 6 Sep 2018 10:21:08 +0100 Subject: [PATCH] Add "description" key for map and list types Take the parameter description from the "desc" key in the Maru parameter specification, just like the other types. --- lib/maru_swagger/params_extractor.ex | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/maru_swagger/params_extractor.ex b/lib/maru_swagger/params_extractor.ex index c6dbcae..09bb6e0 100644 --- a/lib/maru_swagger/params_extractor.ex +++ b/lib/maru_swagger/params_extractor.ex @@ -55,12 +55,15 @@ defmodule MaruSwagger.ParamsExtractor do end defp do_format_param("map", param) do - %{type: "object", properties: param.children |> Enum.map(&format_param/1) |> Enum.into(%{})} + %{type: "object", + description: param.desc || "", + properties: param.children |> Enum.map(&format_param/1) |> Enum.into(%{})} end defp do_format_param("list", param) do %{ type: "array", + description: param.desc || "", items: %{ type: "object", properties: param.children |> Enum.map(&format_param/1) |> Enum.into(%{}) @@ -69,7 +72,9 @@ defmodule MaruSwagger.ParamsExtractor do end defp do_format_param({:list, type}, param) do - %{type: "array", items: do_format_param(type, param)} + %{type: "array", + description: param.desc || "", + items: do_format_param(type, param)} end defp do_format_param(type, param) do