From b194477e732db4f5a59c70114777d507068658c1 Mon Sep 17 00:00:00 2001 From: Eric H Kinzie Date: Wed, 23 Jun 2021 11:43:05 -0400 Subject: [PATCH] Swagger-Plugin: fix json output for single top resource The JSON output has an extraneous comma if the --swagger-top-resource option was provided with a value of either "root" or "operations". Check that more output is to follow before writing a comma. --- plugins/yanger_swagger.erl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/yanger_swagger.erl b/plugins/yanger_swagger.erl index 437b655..6c75496 100644 --- a/plugins/yanger_swagger.erl +++ b/plugins/yanger_swagger.erl @@ -411,7 +411,9 @@ emit_tree(Ctx, [Mod|Mods], AllMods, Fd, Opts) -> [delimiter_nl((MatchVer orelse HasDataNode orelse MatchData) andalso - (MatchOp orelse HasOpNode))]); + (MatchOp orelse HasOpNode) + andalso + (Opts#options.top_resource == all))]); true -> skip end, @@ -424,7 +426,9 @@ emit_tree(Ctx, [Mod|Mods], AllMods, Fd, Opts) -> 'yang-library-version', Opts), io:format(Fd, "~s", [delimiter_nl((HasDataNode orelse MatchData) - andalso MatchVer)]); + andalso MatchVer + andalso + (Opts#options.top_resource == all))]); true -> skip end,