mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-05-04 14:44:36 +02:00
Use ILRepack to include Microsoft.OpenApi as internal (#1290)
* . * Use ILRepack to include Microsoft.OpenApi as internal * ... * OpenApiSpecificationVersion * . * 080 * 4
This commit is contained in:
28
src/WireMock.Net.OpenApiParser/Models/OpenApiDiagnostic.cs
Normal file
28
src/WireMock.Net.OpenApiParser/Models/OpenApiDiagnostic.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using RamlToOpenApiConverter;
|
||||
|
||||
namespace WireMock.Net.OpenApiParser.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Object containing all diagnostic information related to Open API parsing.
|
||||
/// </summary>
|
||||
public class OpenApiDiagnostic
|
||||
{
|
||||
/// <summary>
|
||||
/// List of all errors.
|
||||
/// </summary>
|
||||
public List<OpenApiError> Errors { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// List of all warnings
|
||||
/// </summary>
|
||||
public List<OpenApiError> Warnings { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Open API specification version of the document parsed.
|
||||
/// </summary>
|
||||
public OpenApiSpecificationVersion SpecificationVersion { get; set; }
|
||||
}
|
||||
46
src/WireMock.Net.OpenApiParser/Models/OpenApiError.cs
Normal file
46
src/WireMock.Net.OpenApiParser/Models/OpenApiError.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace WireMock.Net.OpenApiParser.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Error related to the Open API Document.
|
||||
/// </summary>
|
||||
public class OpenApiError
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="OpenApiError"/> class.
|
||||
/// </summary>
|
||||
public OpenApiError(string? pointer, string message)
|
||||
{
|
||||
Pointer = pointer;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a copy of an <see cref="OpenApiError"/> object
|
||||
/// </summary>
|
||||
public OpenApiError(OpenApiError error)
|
||||
{
|
||||
Pointer = error.Pointer;
|
||||
Message = error.Message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Message explaining the error.
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Pointer to the location of the error.
|
||||
/// </summary>
|
||||
public string? Pointer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the string representation of <see cref="OpenApiError"/>.
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Message + (!string.IsNullOrEmpty(Pointer) ? " [" + Pointer + "]" : "");
|
||||
}
|
||||
}
|
||||
25
src/WireMock.Net.OpenApiParser/Models/OpenApiMapper.cs
Normal file
25
src/WireMock.Net.OpenApiParser/Models/OpenApiMapper.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Linq;
|
||||
using RamlToOpenApiConverter;
|
||||
using MicrosoftOpenApiDiagnostic = Microsoft.OpenApi.Reader.OpenApiDiagnostic;
|
||||
|
||||
namespace WireMock.Net.OpenApiParser.Models;
|
||||
|
||||
internal static class OpenApiMapper
|
||||
{
|
||||
internal static OpenApiDiagnostic? Map(MicrosoftOpenApiDiagnostic? openApiDiagnostic)
|
||||
{
|
||||
if (openApiDiagnostic == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new OpenApiDiagnostic
|
||||
{
|
||||
Errors = openApiDiagnostic.Errors.Select(e => new OpenApiError(e.Pointer, e.Message)).ToList(),
|
||||
Warnings = openApiDiagnostic.Warnings.Select(e => new OpenApiError(e.Pointer, e.Message)).ToList(),
|
||||
SpecificationVersion = (OpenApiSpecificationVersion)openApiDiagnostic.SpecificationVersion
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user