mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-11-13 12:23:42 +01:00
Revert to RamlToOpenApiConverter.SourceOnly (#1509)
This commit is contained in:
1 parent
e4389333a1
commit
7db5b562d8
16 files changed
+176
-17
No files matched your search
+1
-3
@@ -6,15 +6,13 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!--<PackageReference Include="Microsoft.OpenApi.YamlReader" Version="3.7.0" />-->
|
|
||||||
|
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net.OpenApiParser\WireMock.Net.OpenApiParser.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net.OpenApiParser\WireMock.Net.OpenApiParser.csproj" />
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net\WireMock.Net.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(Configuration)' == 'Release'">
|
<ItemGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
<PackageReference Include="Microsoft.OpenApi" Version="3.7.0" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.OpenApi" Version="3.10.2" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
|
|
||||||
namespace System.Collections.Generic;
|
namespace System.Collections.Generic;
|
||||||
|
|
||||||
internal static class DictionaryExtensions
|
internal static class DictionaryExtensions
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Microsoft.OpenApi.Reader;
|
|
||||||
using Stef.Validation;
|
using Stef.Validation;
|
||||||
|
using WireMock.Net.OpenApiParser.Models;
|
||||||
using WireMock.Net.OpenApiParser.Settings;
|
using WireMock.Net.OpenApiParser.Settings;
|
||||||
using WireMock.Server;
|
using WireMock.Server;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
|
||||||
|
<!-- See also https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task/issues/26 -->
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Target Name="ILRepacker" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
|
||||||
|
<ItemGroup>
|
||||||
|
<InputAssemblies Include="$(OutputPath)WireMock.Net.OpenApiParser.dll" />
|
||||||
|
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.OpenApi.YamlReader'" />
|
||||||
|
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Microsoft.OpenApi'" />
|
||||||
|
<LibraryPath Include="%(ReferencePathWithRefAssemblies.RelativeDir)" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<DoNotInternalizeAssemblies Include="WireMock.Net.OpenApiParser" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ILRepack
|
||||||
|
Parallel="true"
|
||||||
|
Internalize="true"
|
||||||
|
RenameInternalized="true"
|
||||||
|
InternalizeExclude="@(DoNotInternalizeAssemblies)"
|
||||||
|
InputAssemblies="@(InputAssemblies)"
|
||||||
|
LibraryPath="@(LibraryPath)"
|
||||||
|
TargetKind="Dll"
|
||||||
|
KeyFile="../../src/WireMock.Net/WireMock.Net.snk"
|
||||||
|
OutputFile="$(OutputPath)$(AssemblyName).dll"
|
||||||
|
/>
|
||||||
|
</Target>
|
||||||
|
</Project>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
using Microsoft.OpenApi.Reader;
|
|
||||||
using WireMock.Admin.Mappings;
|
using WireMock.Admin.Mappings;
|
||||||
|
using WireMock.Net.OpenApiParser.Models;
|
||||||
using WireMock.Net.OpenApiParser.Settings;
|
using WireMock.Net.OpenApiParser.Settings;
|
||||||
|
|
||||||
namespace WireMock.Net.OpenApiParser;
|
namespace WireMock.Net.OpenApiParser;
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
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 OpenApiSpecVersion SpecificationVersion { get; set; }
|
||||||
|
}
|
||||||
@@ -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 + "]" : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
|
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 = (OpenApiSpecVersion)openApiDiagnostic.SpecificationVersion
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
|
namespace WireMock.Net.OpenApiParser.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents versions of OpenAPI specification.
|
||||||
|
/// </summary>
|
||||||
|
public enum OpenApiSpecVersion
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents OpenAPI V2.0 spec
|
||||||
|
/// </summary>
|
||||||
|
OpenApi2_0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents all patches of OpenAPI V3.0 spec (e.g. 3.0.0, 3.0.1)
|
||||||
|
/// </summary>
|
||||||
|
OpenApi3_0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents OpenAPI V3.1 spec
|
||||||
|
/// </summary>
|
||||||
|
OpenApi3_1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents OpenAPI V3.2 spec
|
||||||
|
/// </summary>
|
||||||
|
OpenApi3_2
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.OpenApi;
|
using Microsoft.OpenApi;
|
||||||
|
|
||||||
namespace WireMock.Net.OpenApiParser.Settings;
|
namespace WireMock.Net.OpenApiParser.Settings;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.OpenApi;
|
using Microsoft.OpenApi;
|
||||||
using RandomDataGenerator.FieldOptions;
|
using RandomDataGenerator.FieldOptions;
|
||||||
using RandomDataGenerator.Randomizers;
|
using RandomDataGenerator.Randomizers;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.OpenApi;
|
using Microsoft.OpenApi;
|
||||||
|
|
||||||
namespace WireMock.Net.OpenApiParser.Settings;
|
namespace WireMock.Net.OpenApiParser.Settings;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
namespace WireMock.Net.OpenApiParser.Utils;
|
namespace WireMock.Net.OpenApiParser.Utils;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using Microsoft.OpenApi;
|
using Microsoft.OpenApi;
|
||||||
using Stef.Validation;
|
using Stef.Validation;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1' ">
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
|
||||||
<PackageReference Include="Required" Version="1.0.0">
|
<PackageReference Include="Required" Version="1.0.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
@@ -40,11 +40,27 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
<PackageReference Include="RamlToOpenApiConverter" Version="0.40.0" />
|
|
||||||
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.19.1" />
|
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.19.1" />
|
||||||
<PackageReference Include="Stef.Validation" Version="0.3.0" />
|
<PackageReference Include="Stef.Validation" Version="0.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- https://github.com/wiremock/WireMock.Net/issues/1508 -->
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="RamlToOpenApiConverter.SourceOnly" Version="0.40.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
|
||||||
|
<PackageReference Include="Microsoft.OpenApi.YamlReader" Version="3.10.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
|
<!-- Keep at version 2.0.43 (https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task/issues/80) -->
|
||||||
|
<PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.43" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="Microsoft.OpenApi" Version="3.10.2" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="Microsoft.OpenApi.YamlReader" Version="3.10.2" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="SharpYaml" Version="2.1.5" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
<ProjectReference Include="..\..\src\WireMock.Net.Abstractions\WireMock.Net.Abstractions.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ using Microsoft.OpenApi.YamlReader;
|
|||||||
using RamlToOpenApiConverter;
|
using RamlToOpenApiConverter;
|
||||||
using WireMock.Admin.Mappings;
|
using WireMock.Admin.Mappings;
|
||||||
using WireMock.Net.OpenApiParser.Mappers;
|
using WireMock.Net.OpenApiParser.Mappers;
|
||||||
|
using WireMock.Net.OpenApiParser.Models;
|
||||||
using WireMock.Net.OpenApiParser.Settings;
|
using WireMock.Net.OpenApiParser.Settings;
|
||||||
|
using OpenApiDiagnostic = WireMock.Net.OpenApiParser.Models.OpenApiDiagnostic;
|
||||||
|
|
||||||
namespace WireMock.Net.OpenApiParser;
|
namespace WireMock.Net.OpenApiParser;
|
||||||
|
|
||||||
@@ -125,7 +127,7 @@ public class WireMockOpenApiParser : IWireMockOpenApiParser
|
|||||||
|
|
||||||
var result = OpenApiDocument.Load(memoryStream, settings: _readerSettings);
|
var result = OpenApiDocument.Load(memoryStream, settings: _readerSettings);
|
||||||
|
|
||||||
diagnostic = result.Diagnostic ?? new OpenApiDiagnostic();
|
diagnostic = OpenApiMapper.Map(result.Diagnostic) ?? new OpenApiDiagnostic();
|
||||||
openApiDocument = result.Document;
|
openApiDocument = result.Document;
|
||||||
return openApiDocument != null && !diagnostic.Errors.Any();
|
return openApiDocument != null && !diagnostic.Errors.Any();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user