Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using System.Collections.Generic;

namespace Microsoft.OpenApi.Readers.Interface
{
/// <summary>
/// Interface for the log
/// Interface for the entity containing diagnostic information from the reading process.
/// </summary>
/// <typeparam name="TError">Type of recorded errors</typeparam>
public interface ILog<TError>
public interface IDiagnostic
{
/// <summary>
/// List of recorded errors.
/// </summary>
IList<TError> Errors { get; set; }
}
}
13 changes: 5 additions & 8 deletions src/Microsoft.OpenApi.Readers/Interface/IOpenApiReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using SharpYaml.Serialization.Logging;

namespace Microsoft.OpenApi.Readers.Interface
{
/// <summary>
/// Interface for open API readers.
/// Interface for Open API readers.
/// </summary>
/// <typeparam name="TInput">The type of input to read from.</typeparam>
/// <typeparam name="TLog">The type of log for information from reading process.</typeparam>
/// <typeparam name="TError">The type of the recorded error from the reading process.</typeparam>
public interface IOpenApiReader<TInput, TLog, TError> where TLog : ILog<TError>
/// <typeparam name="TDiagnostic">The type of diagnostic for information from reading process.</typeparam>
public interface IOpenApiReader<TInput, TDiagnostic> where TDiagnostic : IDiagnostic
{
/// <summary>
/// Reads the input and parses it into an Open API document.
/// </summary>
/// <param name="input">The input to read from.</param>
/// <param name="log">The log or context containing information from the reading process.</param>
/// <param name="diagnostic">The diagnostic entity containing information from the reading process.</param>
/// <returns>The Open API document.</returns>
OpenApiDocument Read(TInput input, out TLog log);
OpenApiDocument Read(TInput input, out TDiagnostic diagnostic);
}
}
47 changes: 0 additions & 47 deletions src/Microsoft.OpenApi.Readers/YamlReaders/ListNode.cs

This file was deleted.

139 changes: 0 additions & 139 deletions src/Microsoft.OpenApi.Readers/YamlReaders/MapNode.cs

This file was deleted.

15 changes: 15 additions & 0 deletions src/Microsoft.OpenApi.Readers/YamlReaders/OpenApiDiagnostic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// ------------------------------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the copyright is different with the core. Which one do we should take?

Copy link
Contributor Author

@PerthCharern PerthCharern Oct 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.opensource.microsoft.com/releasing/copyright-headers.html suggests this:

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using System.Collections.Generic;
using Microsoft.OpenApi.Readers.Interface;

namespace Microsoft.OpenApi.Readers.YamlReaders
{
public class OpenApiDiagnostic : IDiagnostic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public the interface, but internal the implement. Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be public I believe. The consumer should have access to the Diagnostic. This is one of the reasons it gets refactored out of ParsingContext

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the things customers want to access into interface, hide the detail in the implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't know what the customers want. That's why the Interface has nothing. Each reader can implement its own IDiagnostic

{
public IList<OpenApiError> Errors { get; set; } = new List<OpenApiError>();
}
}
20 changes: 12 additions & 8 deletions src/Microsoft.OpenApi.Readers/YamlReaders/OpenApiError.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
using Microsoft.OpenApi.Readers.Interface;
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

namespace Microsoft.OpenApi.Readers.YamlReaders
{
public class OpenApiError
{
string pointer;
string message;
private readonly string message;
private readonly string pointer;

public OpenApiError(OpenApiException ex)
public OpenApiError(OpenApiException exception)
{
this.message = ex.Message;
this.pointer = ex.Pointer;
message = exception.Message;
pointer = exception.Pointer;
}

public OpenApiError(string pointer, string message)
{
this.pointer = pointer;
Expand All @@ -20,7 +24,7 @@ public OpenApiError(string pointer, string message)

public override string ToString()
{
return this.message + (!string.IsNullOrEmpty(this.pointer) ? " at " + this.pointer : "");
return message + (!string.IsNullOrEmpty(pointer) ? " at " + pointer : "");
}
}
}
}
Loading