Skip to content

Commit 48685d3

Browse files
committed
make default parameter overloads binary compatible
1 parent a45aaa0 commit 48685d3

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs

100644100755
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ public static void SerializeAsYaml<T>(this T element, Stream stream, OpenApiSpec
4141
element.Serialize(stream, specVersion, OpenApiFormat.Yaml);
4242
}
4343

44+
/// <summary>
45+
/// Serializes the <see cref="IOpenApiSerializable"/> to the Open API document using
46+
/// the given stream, specification version and the format.
47+
/// </summary>
48+
/// <typeparam name="T">the <see cref="IOpenApiSerializable"/></typeparam>
49+
/// <param name="element">The Open API element.</param>
50+
/// <param name="stream">The given stream.</param>
51+
/// <param name="specVersion">The Open API specification version.</param>
52+
/// <param name="format">The output format (JSON or YAML).</param>
53+
public static void Serialize<T>(
54+
this T element,
55+
Stream stream,
56+
OpenApiSpecVersion specVersion,
57+
OpenApiFormat format)
58+
where T : IOpenApiSerializable
59+
{
60+
element.Serialize(stream, specVersion, format, null);
61+
}
62+
4463
/// <summary>
4564
/// Serializes the <see cref="IOpenApiSerializable"/> to the Open API document using
4665
/// the given stream, specification version and the format.
@@ -56,7 +75,7 @@ public static void Serialize<T>(
5675
Stream stream,
5776
OpenApiSpecVersion specVersion,
5877
OpenApiFormat format,
59-
OpenApiWriterSettings settings = null)
78+
OpenApiWriterSettings settings)
6079
where T : IOpenApiSerializable
6180
{
6281
if (stream == null)

src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs

100644100755
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@ namespace Microsoft.OpenApi.Writers
1010
/// </summary>
1111
public class OpenApiJsonWriter : OpenApiWriterBase
1212
{
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="OpenApiJsonWriter"/> class.
15+
/// </summary>
16+
/// <param name="textWriter">The text writer.</param>
17+
public OpenApiJsonWriter(TextWriter textWriter) : base(textWriter, null)
18+
{
19+
}
20+
1321
/// <summary>
1422
/// Initializes a new instance of the <see cref="OpenApiJsonWriter"/> class.
1523
/// </summary>
1624
/// <param name="textWriter">The text writer.</param>
1725
/// <param name="settings">Settings for controlling how the OpenAPI document will be written out.</param>
18-
public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings = null) : base(textWriter, settings)
26+
public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings) : base(textWriter, settings)
1927
{
2028
}
2129

src/Microsoft.OpenApi/Writers/OpenApiWriterBase.cs

100644100755
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Collections.Generic;
66
using System.IO;
77
using Microsoft.OpenApi.Exceptions;
8-
using Microsoft.OpenApi.Models;
98
using Microsoft.OpenApi.Properties;
109

1110
namespace Microsoft.OpenApi.Writers

src/Microsoft.OpenApi/Writers/OpenApiYamlWriter.cs

100644100755
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ namespace Microsoft.OpenApi.Writers
1010
/// </summary>
1111
public class OpenApiYamlWriter : OpenApiWriterBase
1212
{
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="OpenApiYamlWriter"/> class.
15+
/// </summary>
16+
/// <param name="textWriter">The text writer.</param>
17+
public OpenApiYamlWriter(TextWriter textWriter) : this(textWriter, null)
18+
{
19+
}
20+
1321
/// <summary>
1422
/// Initializes a new instance of the <see cref="OpenApiYamlWriter"/> class.
1523
/// </summary>
1624
/// <param name="textWriter">The text writer.</param>
1725
/// <param name="settings"></param>
18-
public OpenApiYamlWriter(TextWriter textWriter, OpenApiWriterSettings settings = null) : base(textWriter, settings)
26+
public OpenApiYamlWriter(TextWriter textWriter, OpenApiWriterSettings settings) : base(textWriter, settings)
1927
{
20-
2128
}
2229

2330
/// <summary>

0 commit comments

Comments
 (0)