Skip to content

Commit e9fdbfb

Browse files
authored
Merge pull request #30 from Microsoft/PerthCharern/RefactorParsingContext
Refactor OpenApiDiagnostic out of ParsingContext
2 parents 256d86f + f7f49e4 commit e9fdbfb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1276
-1080
lines changed

src/Microsoft.OpenApi.Readers/Interface/ILog.cs renamed to src/Microsoft.OpenApi.Readers/Interface/IDiagnostic.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,12 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6-
using System.Collections.Generic;
7-
86
namespace Microsoft.OpenApi.Readers.Interface
97
{
108
/// <summary>
11-
/// Interface for the log
9+
/// Interface for the entity containing diagnostic information from the reading process.
1210
/// </summary>
13-
/// <typeparam name="TError">Type of recorded errors</typeparam>
14-
public interface ILog<TError>
11+
public interface IDiagnostic
1512
{
16-
/// <summary>
17-
/// List of recorded errors.
18-
/// </summary>
19-
IList<TError> Errors { get; set; }
2013
}
2114
}

src/Microsoft.OpenApi.Readers/Interface/IOpenApiReader.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,21 @@
33
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
44
// ------------------------------------------------------------
55

6-
using SharpYaml.Serialization.Logging;
7-
86
namespace Microsoft.OpenApi.Readers.Interface
97
{
108
/// <summary>
11-
/// Interface for open API readers.
9+
/// Interface for Open API readers.
1210
/// </summary>
1311
/// <typeparam name="TInput">The type of input to read from.</typeparam>
14-
/// <typeparam name="TLog">The type of log for information from reading process.</typeparam>
15-
/// <typeparam name="TError">The type of the recorded error from the reading process.</typeparam>
16-
public interface IOpenApiReader<TInput, TLog, TError> where TLog : ILog<TError>
12+
/// <typeparam name="TDiagnostic">The type of diagnostic for information from reading process.</typeparam>
13+
public interface IOpenApiReader<TInput, TDiagnostic> where TDiagnostic : IDiagnostic
1714
{
1815
/// <summary>
1916
/// Reads the input and parses it into an Open API document.
2017
/// </summary>
2118
/// <param name="input">The input to read from.</param>
22-
/// <param name="log">The log or context containing information from the reading process.</param>
19+
/// <param name="diagnostic">The diagnostic entity containing information from the reading process.</param>
2320
/// <returns>The Open API document.</returns>
24-
OpenApiDocument Read(TInput input, out TLog log);
21+
OpenApiDocument Read(TInput input, out TDiagnostic diagnostic);
2522
}
2623
}

src/Microsoft.OpenApi.Readers/YamlReaders/ListNode.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/Microsoft.OpenApi.Readers/YamlReaders/MapNode.cs

Lines changed: 0 additions & 139 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// ------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
4+
// ------------------------------------------------------------
5+
6+
using System.Collections.Generic;
7+
using Microsoft.OpenApi.Readers.Interface;
8+
9+
namespace Microsoft.OpenApi.Readers.YamlReaders
10+
{
11+
public class OpenApiDiagnostic : IDiagnostic
12+
{
13+
public IList<OpenApiError> Errors { get; set; } = new List<OpenApiError>();
14+
}
15+
}
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
using Microsoft.OpenApi.Readers.Interface;
1+
// ------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
4+
// ------------------------------------------------------------
25

36
namespace Microsoft.OpenApi.Readers.YamlReaders
47
{
58
public class OpenApiError
69
{
7-
string pointer;
8-
string message;
10+
private readonly string message;
11+
private readonly string pointer;
912

10-
public OpenApiError(OpenApiException ex)
13+
public OpenApiError(OpenApiException exception)
1114
{
12-
this.message = ex.Message;
13-
this.pointer = ex.Pointer;
15+
message = exception.Message;
16+
pointer = exception.Pointer;
1417
}
18+
1519
public OpenApiError(string pointer, string message)
1620
{
1721
this.pointer = pointer;
@@ -20,7 +24,7 @@ public OpenApiError(string pointer, string message)
2024

2125
public override string ToString()
2226
{
23-
return this.message + (!string.IsNullOrEmpty(this.pointer) ? " at " + this.pointer : "");
27+
return message + (!string.IsNullOrEmpty(pointer) ? " at " + pointer : "");
2428
}
2529
}
26-
}
30+
}

0 commit comments

Comments
 (0)