Skip to content

Commit afba9d8

Browse files
committed
Pass the terseOutput option provided to the OpenApiWriter settings for serializing JSON in a terse format
1 parent 2bf6b36 commit afba9d8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static async Task<int> TransformOpenApiDocument(
4444
bool cleanoutput,
4545
string? version,
4646
OpenApiFormat? format,
47+
bool terseOutput,
4748
LogLevel loglevel,
4849
bool inlineLocal,
4950
bool inlineExternal,
@@ -188,11 +189,13 @@ CancellationToken cancellationToken
188189
using var outputStream = output?.Create();
189190
var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out;
190191

191-
var settings = new OpenApiWriterSettings()
192+
var settings = new OpenApiWriterSettings();
193+
if (terseOutput)
192194
{
193-
InlineLocalReferences = inlineLocal,
194-
InlineExternalReferences = inlineExternal
195-
};
195+
settings.Terse = terseOutput;
196+
}
197+
settings.InlineLocalReferences = inlineLocal;
198+
settings.InlineExternalReferences = inlineExternal;
196199

197200
IOpenApiWriter writer = openApiFormat switch
198201
{

src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public OpenApiJsonWriter(TextWriter textWriter, OpenApiJsonWriterSettings settin
3535
/// <param name="settings">Settings for controlling how the OpenAPI document will be written out.</param>
3636
public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings) : base(textWriter, settings)
3737
{
38+
_produceTerseOutput = settings.Terse;
3839
}
3940

4041
/// <summary>

0 commit comments

Comments
 (0)