Skip to content

Commit ee63758

Browse files
committed
Abstract implementation detail from interface
1 parent 56742b9 commit ee63758

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Microsoft.OpenApi.Readers
2121
public class OpenApiYamlReader : IOpenApiReader
2222
{
2323
private const int copyBufferSize = 4096;
24+
private static readonly OpenApiJsonReader _jsonReader = new();
2425

2526
/// <inheritdoc/>
2627
public async Task<ReadResult> ReadAsync(Stream input,
@@ -70,9 +71,9 @@ public ReadResult Read(MemoryStream input,
7071
}
7172

7273
/// <inheritdoc/>
73-
public ReadResult Read(JsonNode jsonNode, OpenApiReaderSettings settings, string format = null)
74+
public static ReadResult Read(JsonNode jsonNode, OpenApiReaderSettings settings, string format = null)
7475
{
75-
return OpenApiReaderRegistry.DefaultReader.Read(jsonNode, settings, OpenApiConstants.Yaml);
76+
return _jsonReader.Read(jsonNode, settings, OpenApiConstants.Yaml);
7677
}
7778

7879
/// <inheritdoc/>
@@ -101,9 +102,9 @@ public T ReadFragment<T>(MemoryStream input,
101102
}
102103

103104
/// <inheritdoc/>
104-
public T ReadFragment<T>(JsonNode input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic, OpenApiReaderSettings settings = null) where T : IOpenApiElement
105+
public static T ReadFragment<T>(JsonNode input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic, OpenApiReaderSettings settings = null) where T : IOpenApiElement
105106
{
106-
return OpenApiReaderRegistry.DefaultReader.ReadFragment<T>(input, version, out diagnostic, settings);
107+
return _jsonReader.ReadFragment<T>(input, version, out diagnostic, settings);
107108
}
108109

109110
/// <summary>

src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ public interface IOpenApiReader
3131
/// <returns></returns>
3232
ReadResult Read(MemoryStream input, OpenApiReaderSettings settings);
3333

34-
/// <summary>
35-
/// Parses the JsonNode input into an Open API document.
36-
/// </summary>
37-
/// <param name="jsonNode">The JsonNode input.</param>
38-
/// <param name="settings">The Reader settings to be used during parsing.</param>
39-
/// <param name="format">The OpenAPI format.</param>
40-
/// <returns></returns>
41-
ReadResult Read(JsonNode jsonNode, OpenApiReaderSettings settings, string format = null);
42-
4334
/// <summary>
4435
/// Reads the MemoryStream and parses the fragment of an OpenAPI description into an Open API Element.
4536
/// </summary>
@@ -49,15 +40,5 @@ public interface IOpenApiReader
4940
/// <param name="settings">The OpenApiReader settings.</param>
5041
/// <returns>Instance of newly created IOpenApiElement.</returns>
5142
T ReadFragment<T>(MemoryStream input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic, OpenApiReaderSettings settings = null) where T : IOpenApiElement;
52-
53-
/// <summary>
54-
/// Reads the JsonNode input and parses the fragment of an OpenAPI description into an Open API Element.
55-
/// </summary>
56-
/// <param name="input">Memory stream containing OpenAPI description to parse.</param>
57-
/// <param name="version">Version of the OpenAPI specification that the fragment conforms to.</param>
58-
/// <param name="diagnostic">Returns diagnostic object containing errors detected during parsing.</param>
59-
/// <param name="settings">The OpenApiReader settings.</param>
60-
/// <returns>Instance of newly created IOpenApiElement.</returns>
61-
T ReadFragment<T>(JsonNode input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic, OpenApiReaderSettings settings = null) where T : IOpenApiElement;
6243
}
6344
}

test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,9 @@ namespace Microsoft.OpenApi.Interfaces
220220
public interface IOpenApiReader
221221
{
222222
Microsoft.OpenApi.Reader.ReadResult Read(System.IO.MemoryStream input, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings);
223-
Microsoft.OpenApi.Reader.ReadResult Read(System.Text.Json.Nodes.JsonNode jsonNode, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings, string format = null);
224223
System.Threading.Tasks.Task<Microsoft.OpenApi.Reader.ReadResult> ReadAsync(System.IO.Stream input, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings, System.Threading.CancellationToken cancellationToken = default);
225224
T ReadFragment<T>(System.IO.MemoryStream input, Microsoft.OpenApi.OpenApiSpecVersion version, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null)
226225
where T : Microsoft.OpenApi.Interfaces.IOpenApiElement;
227-
T ReadFragment<T>(System.Text.Json.Nodes.JsonNode input, Microsoft.OpenApi.OpenApiSpecVersion version, out Microsoft.OpenApi.Reader.OpenApiDiagnostic diagnostic, Microsoft.OpenApi.Reader.OpenApiReaderSettings settings = null)
228-
where T : Microsoft.OpenApi.Interfaces.IOpenApiElement;
229226
}
230227
public interface IOpenApiReferenceable : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiSerializable
231228
{

0 commit comments

Comments
 (0)